Excel VBA remove duplicates
Posted on 2012-03-12
I have a bit of code to remove duplicates as follows:
ActiveSheet.Range(Cells(1, 1), Cells(lastrow, 25)).RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5), Header:=xlYes
This works fine but sometime there are not 5 columns of data so the macro breaks.
Following this I was wondering, assuming I have ColNo as the variable representing the number of columns in the array, what I would have as the code?