.Removeduplicates fails, "invalid procedure call"

donfaison

New Member
Joined
Jan 7, 2014
Messages
21
Office Version
  1. 365
Platform
  1. Windows
I have tried the following but nothing works.

Recording the steps yields
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Range("$A$1:$D$338").RemoveDuplicates Columns:=Array(1, 2, 3, 4), Header:=xlYes
However, actually running the macro I get an error (5) on the last line, "invalid procedure call or argument".
I have tried
Range("$A$1:$D$338").Select
Selection.RemoveDuplicates Columns:=Array(1, 2, 3, 4), Header:=xlYes
and just
Range("$A$1:$D$338").RemoveDuplicates Columns:=Array(1, 2, 3, 4), Header:=xlYes
and a couple of minor variations I have seen online line but everything creates the same error. What am I missing?
Windows 10, MS Excel 365
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Did you try:

VBA Code:
Range("$A$1:$D$338").RemoveDuplicates Columns:=VBA.Array(1, 2, 3, 4), Header:=xlYes
 
Upvote 0
Solution
Windows 10, MS Excel 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
This line works quite happily for me
VBA Code:
ActiveSheet.Range("$A$1:$D$338").RemoveDuplicates Columns:=Array(1, 2, 3, 4), Header:=xlYes
 
Upvote 0
One reason could be if you have
Option Base 1
somewhere in your code.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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