Link to home
Start Free TrialLog in
Avatar of Euro5
Euro5Flag for United States of America

asked on

VBA code error on duplication

I am getting an error on the following code to remove dups.
The error is on Range("A1").CurrentRegion.RemoveDuplicates Columns:=(varColArray), Header:=xlNo

I am attaching sample. Can anyone help?
The code should remove lines where ALL columns are the same.
Thanks!

Sub removedups()


Dim varColArray As Variant
Dim intCol As Integer

ReDim varColArray(0 To ActiveSheet.UsedRange.Columns.Count - 1)

For intCol = 1 To ActiveSheet.UsedRange.Columns.Count
    varColArray(intCol - 1) = intCol
Next

Range("A1").CurrentRegion.RemoveDuplicates Columns:=(varColArray), Header:=xlNo
End Sub

Open in new window

sample.xlsm
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

What error do you get?
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Euro5

ASKER

Yes, it works perfectly! Thanks so much.
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you including these two new ones.
Creating your own Excel Formulas and doing the impossible
A Guide to Writing Understandable and Maintainable VBA Code
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
Avatar of Euro5

ASKER

Thanks! I will check them out!