Module will not run

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
:eeek:
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Erica

Do you get any error message?

If you do can you post it, that might help us identify the problem.:)

xld

As far as I'm aware you don't need to specify a criteria range - it's an optional argument.

Obviously most of the time you would but if all the code is meant to do is get uniques it shouldn't be needed.:)
 
Upvote 0
Hi Erica

Change:
Code:
FinalRow = Cells(Row.Count, 1).End(xlUp).Row
To:
Code:
FinalRow = Cells(Row[COLOR=Red][B]s[/B][/COLOR].Count, 1).End(xlUp).Row
 
Upvote 0
Erica

Do you get any error message?

If you do can you post it, that might help us identify the problem.:)

xld

As far as I'm aware you don't need to specify a criteria range - it's an optional argument.

Obviously most of the time you would but if all the code is meant to do is get uniques it shouldn't be needed.:)

I know Norie, but I was wondering what was her unique key without criteria. I guess it was the whole row (which to my mind is nonsense).
 
Upvote 0
Good point, never thought of that.

Suppose I just assumed that it was the one column being filtered to get the unique values.:)
 
Upvote 0

Forum statistics

Threads
1,224,455
Messages
6,178,772
Members
452,875
Latest member
Disastrouscoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top