code help cont.

S

scrabtree

Sheets("Stepdown").Select
Columns("B:B").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Worksheets("Stepdown2") _
.Range("A1"), Unique:=True


This only copied Column B:B to the Stepdown2 sheet. I
wanted the whole table copied not just column B:B?
 
T

Tom Ogilvy

Your code tells it to only use column B. Tell it to use the whole table:
Sheets("Stepdown").Select
range("B1").CurrentRegion.AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Worksheets("Stepdown2") _
.Range("A1"), Unique:=True

Obviously I can't see your sheet or know how your data is laid out. so you
substitute in the best way to get the "table" or what you want treated as a
table.

However, note that if you only want rows that are unique with respect to
column B, then you would need to filter in place, then copy

Dim rng as Range, rng1 as Range
Sheets("Stepdown").Select
Columns("B:B").AdvancedFilter _
Action:=xlFilterInPlace, _
Unique:=True
set rng = Columns("B:B").SpecialCells(xlVisible)
set rng1 = Intersect(Range("b1").CurrentRegion, rng.Entirerow)
rng1.copy Destination:=Worksheets("Stepdown2") _
.Range("A1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top