PDA

View Full Version : [SOLVED] Flexible copy-to range



K. Georgiadis
07-03-2005, 07:27 AM
In the following code, unique records are copied to a new range starting with cell A56. How can I amend this so that it just starts copying 3 rows down from the last populated row wherever that might be?


Sub filter_unique_records()
Sheets("Pivot Data").Select
Range("A3:I49").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"A56"), Unique:=True
End Sub

Norie
07-03-2005, 07:38 AM
Try this.



Sub filter_unique_records()
Dim ws As Worksheet
Dim LastRow As Long
Set ws = Sheets("Pivot Data")
LastRow = ws.Range("A65536").End(xlUp).Row
ws.Range("A3:I49").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ws.Range("A" & (LastRow + 3)), Unique:=True
End Sub

K. Georgiadis
07-03-2005, 02:48 PM
works perfectly. Thanks!!:beerchug: