How to loop through a range of data to remove duplicates
I am trying to create a macro that goes through 9 rows of data to remove duplicates then move to the next 9 rows and preform the same remove duplicates function.
Currently I have...
ActiveWindow.SmallScroll Down:=15
Range("A184:E192").Select
ActiveSheet.Range("$A$184:$E$192").RemoveDuplicates Columns:=5, Header:= _
xlNo
Range("A193:E201").Select
ActiveSheet.Range("$A$193:$E$201").RemoveDuplicates Columns:=5, Header:= _
xlNo
ActiveWindow.SmallScroll Down:=18
Range("A202:E210").Select
ActiveSheet.Range("$A$202:$E$210").RemoveDuplicates Columns:=5, Header:= _
xlNo
Range("A211:E219").Select
ActiveSheet.Range("$A$211:$E$219").RemoveDuplicates Columns:=5, Header:= _
xlNo
End Sub
but I would like it to continuously go through A+9 : E + 9 until it reaches A1500:E1508. Any help would be great, Thanks!
Give this a shot
Sub dupes()
Dim i As Integer
Dim e As Integer
Dim c As Integer
e = 1500 'Last Row
For c = 1 To 5 'c =Column Number start
For i = 1 To e 'i = Row start number. e = Row stop number
Range(Cells(i, c), Cells(i + 9, c)).RemoveDuplicates Columns:=1
i = i + 9
Next i
Next c
End Sub