Link to home
Start Free TrialLog in
Avatar of Legolas786
Legolas786

asked on

Delete rows if they are duplicates

Hi,

I have data in columns A to columns I, what I am trying to achieve is to run some VBA coding which will remove any duplicates rows so only the one unique line remains, so for example if there are 2, 3, or 5 identical rows of data only 1 line will remain.  I only want to delete the rows if all rows match so column A to column I.


So far I have got to the following

Sub DeleteRows()

With ActiveSheet
Set Rng = Range("A1", Range("B1").End(xlDown))
Rng.RemoveDuplicates Columns:=Array(1,2), Header:=xlYes
EndWith

EndSub

Open in new window



But when I implement this code to help me with further columns the result is not what I expected as it looks like its deleted over half my data and data where i know there are no duplicates?

Any idea where i have gone wrong? thanks

Sub DeleteRows()

With ActiveSheet
Set Rng = Range("A1", Range("I1").End(xlDown))
Rng.RemoveDuplicates Columns:=Array(1,9), Header:=xlYes
EndWith

EndSub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

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
If Kimputer's solution doesn't work for you then please attach your workbook.
Avatar of Legolas786
Legolas786

ASKER

Thanks, cant believe it was as simple as that