ericaindallas
New Member
- Joined
- Aug 20, 2009
- Messages
- 45
I'm trying to run a somewhat generic VBA code from one of Mr. Jelen's books (VBA and Macros for MS Office Excel 2007). I'm trying to extract a unique list of values. [Besides using the "Remove Duplicates" function].
I have my dataset in Book1, Sheet1, beginning in cell A1.
Here is the code...
Sub GetUniqueCustomers()
Dim IRange As Range
Dim ORange As Range
'Find the size of today's dataset
FinalRow = Cells(Row.Count, 1).End(xlUp).Row
NextCol = Cells(1, Columns.Count).End(xlToLeft).Column + 2
'Set up output range. Copy heading from J1 there
Range("J1").Copy Destination:=Cells(1, NextCol)
Set ORange = Cells(1, NextCol)
'Define the Input Range
Set IRange = Range("A1").Resize(FinalRow, NextCol - 2)
'Do the Advanced Filter to get unique list of customers
IRange.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ORange, Unique:=True
End Sub
When I run this I get an error, "Run-time error '424': Object required".
Your help is appreciated!!
Thanks -Erica
I have my dataset in Book1, Sheet1, beginning in cell A1.
Here is the code...
Sub GetUniqueCustomers()
Dim IRange As Range
Dim ORange As Range
'Find the size of today's dataset
FinalRow = Cells(Row.Count, 1).End(xlUp).Row
NextCol = Cells(1, Columns.Count).End(xlToLeft).Column + 2
'Set up output range. Copy heading from J1 there
Range("J1").Copy Destination:=Cells(1, NextCol)
Set ORange = Cells(1, NextCol)
'Define the Input Range
Set IRange = Range("A1").Resize(FinalRow, NextCol - 2)
'Do the Advanced Filter to get unique list of customers
IRange.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ORange, Unique:=True
End Sub
When I run this I get an error, "Run-time error '424': Object required".
Your help is appreciated!!
Thanks -Erica