I have a list of data and columns c,d, and e have all unique data. however some companies have more than one entry, and their name appears sometimes 8 times. I want to eliminate all but the topmost company name from t he dups. I'm assuming I need a switch statement, but I'm not sure. any ideas?
here's an example; i've highlighted in red what I mean should be deleted. I recenty figured out that a Switch statement is actually called Select in VB.
this code does not search the whole sheet for duplicates, only if they are grouped together
VB Code:
Sub test()
Dim mystr As String, i As Integer
mystr = Cells(1, 2)
For i = 2 To Sheet1.UsedRange.Rows.Count
If Cells(i, 2) = mystr Then Cells(i, 2) = ""
If Not Cells(i, 2) = "" Then mystr = Cells(i, 2)
Next
End Sub
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete