I have used logic from other stack exchange problems with a similar issue but I CANNOT figure it out. (good examples looked at here: VBa conditional delete loop not working ) I'm sure it is really simple. Why is my code getting stuck in an endless loop here?
I'm just replacing a value and then deleting a range of rows. Any ideas what's wrong? Double loop issue possibly? I've looked at it too long and it all seems logical to me. Any help would be much appreciated.
i = 4
Do While i < 10
j = 0
Do While j < 24
ho = Cells(i, 69 + j)
If 0 < ho < 3 Then
k = Cells(i, 67 + j)
Cells(i - 1, 67 + j) = k
Range(Cells(i, 66 + j), Cells(i, 69 + j)).Delete (xlShiftUp)
Else
j = j + 4
End If
Loop
i = i + 1
Loop
Change your if statement. This will stop it when there is no more data.
If 0 < ho AND ho < 3 AND ho<>"" Then
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.