M
Michael Conroy
I have data being pasted into a worksheet from which I need to do a unique
sort on the first column (EmployeeID) and copy the results to another
worksheet. My problem is with referencing the range address. Since the number
of rows can vary, what is the proper way to get that full range into the
source line. So far I have this:
Dim SourceArea, TargetArea as Variant
Set TargetArea = Application.Sheets("Current").Range("A5")
Application.Sheets("Working").Activate
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select '<-Gets all rows
Set SourceArea = ActiveCell.Address
Range([SourceArea]).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range([TargetArea]), Unique:=True
If Excel has a better way to reference a range, please let me know. My first
instinct is to assign it to a variable. As always thanks for the help.
sort on the first column (EmployeeID) and copy the results to another
worksheet. My problem is with referencing the range address. Since the number
of rows can vary, what is the proper way to get that full range into the
source line. So far I have this:
Dim SourceArea, TargetArea as Variant
Set TargetArea = Application.Sheets("Current").Range("A5")
Application.Sheets("Working").Activate
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select '<-Gets all rows
Set SourceArea = ActiveCell.Address
Range([SourceArea]).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range([TargetArea]), Unique:=True
If Excel has a better way to reference a range, please let me know. My first
instinct is to assign it to a variable. As always thanks for the help.