ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code help cont. (https://www.excelbanter.com/excel-programming/305672-code-help-cont.html)

scrabtree[_2_]

code help cont.
 
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?


Tom Ogilvy

code help cont.
 
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")



--
Regards,
Tom Ogilvy




"scrabtree" wrote in message
...
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?





All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com