VBA_Debutant
New Member
- Joined
- Aug 5, 2011
- Messages
- 6
Hello,
Sorry to post something just to have my macro reviewed, but I have been wasting hours trying to figure out what's wrong.
I have a big file with repeated items in column B.
For example let's say that I have in column A different regions, in B different items and in C the date of item creation in the database. I don't care about the detail of items per region, I just want to keep the item creation date for each item.
I have tried to delete unnecessary lines by doing this (the file is sorted by items so all repeated items are together):
Sub TESTKeep1stLines()
Dim i As Long
Dim y As Long
i = 2
Do While IsEmpty(Cells(i, 1)) = False
y = i - 1
If Cells(i, 2).Value = Cells(y, 2).Value Then
Cells(i, 2).EntireRow.Delete
Else: i = i + 1
End If
Loop
End Sub
But it does not work (I have to hi ESC to end the macro and nothing was done). When I check the Debugger it shows the "End If" line highlighted.
Anyone has any idea what's wrong?
Thank you so much
Sorry to post something just to have my macro reviewed, but I have been wasting hours trying to figure out what's wrong.
I have a big file with repeated items in column B.
For example let's say that I have in column A different regions, in B different items and in C the date of item creation in the database. I don't care about the detail of items per region, I just want to keep the item creation date for each item.
I have tried to delete unnecessary lines by doing this (the file is sorted by items so all repeated items are together):
Sub TESTKeep1stLines()
Dim i As Long
Dim y As Long
i = 2
Do While IsEmpty(Cells(i, 1)) = False
y = i - 1
If Cells(i, 2).Value = Cells(y, 2).Value Then
Cells(i, 2).EntireRow.Delete
Else: i = i + 1
End If
Loop
End Sub
But it does not work (I have to hi ESC to end the macro and nothing was done). When I check the Debugger it shows the "End If" line highlighted.
Anyone has any idea what's wrong?
Thank you so much