Euro5
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. RemoveDupl icates Columns:=(varColArray), Header:=xlNo
I am attaching sample. Can anyone help?
The code should remove lines where ALL columns are the same.
Thanks!
The error is on Range("A1").CurrentRegion.
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
sample.xlsm
What error do you get?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
Thanks! I will check them out!