BACK2BASIC
New member
- Joined
- Oct 14, 2013
- Messages
- 25
- Reaction score
- 0
- Points
- 0
Hello for anyone willing to help me with this application, I would greatly appreciate it. I am not sure..., well I am sure it is not the best way, since it does not work, but what I have is a loop which tests two consecutive rows (field two) for them if equal. If they are equal I want to delete one row and move on. The code works OK until the end when each field equals Null. For some reason, even thought the watch point says the fields are empty, I cannot get a break from the loop.
Please advise as to my ignorance.......Thank you all
For y = 1 To 211
WR = Cells(y, 2)
WT = Cells(y + 1, 2)
If WR = WT Then
Cells(y + 1, 2).Select
Selection.EntireRow.Delete 'they are equal delete row
If WR = Null And WT = Null Then ' test if both fields are null and break
GoTo Break
End If
y = y - 2
Else ' not equal move on
y = y - 1
End If
y = y + 1
Next y
Break:
Please advise as to my ignorance.......Thank you all
For y = 1 To 211
WR = Cells(y, 2)
WT = Cells(y + 1, 2)
If WR = WT Then
Cells(y + 1, 2).Select
Selection.EntireRow.Delete 'they are equal delete row
If WR = Null And WT = Null Then ' test if both fields are null and break
GoTo Break
End If
y = y - 2
Else ' not equal move on
y = y - 1
End If
y = y + 1
Next y
Break: