Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Loop Range Referencing Macro

Status
Not open for further replies.

dab4242

Technical User
Dec 11, 2003
4
US
Hi Guys-

Any help would be much appreciated. I have a range of data (names) that I am trying to loop through and delete any instances where the name is repeating. Here is what I have so far.

Sub RemoveDuplicates()

Dim c As Range
Dim d As Range

Dim a, b, y, x, z, NewVal

For Each c In Range("A1:A2000")
x = c.Value

'run into trouble here referencing new range.

If d.Value = x Then
d.Value = " "
End If


Next

End Sub

I want to begin looking at the rest of the range for the duplicates. How do I reference a range that will begin one cell below where the above range is getting its value. So if A1 is Dan I want to delete all instances of Dan in the range of A2:A2000 or if I was on A2 begin comparing that value with the range A3:A2000. I know this is most likely an easy statement but it is totally slipping my mind. Appreciate your help.

Dan
 
Thanks Skip!!! I'm always making things more difficult than they need to be.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top