Hello there,
I ran the code before on a spreadsheet with a number of lines. I basically want to remove any lines with the value in column C starting with 'M'. As there wouldn't be two blank rows in a row anywhere on the sheet apart from at the end of the filled range, I used the loop conditions below. So when there are two blank rows in a row, the loop should stop. However, for some reason this loop does not stop but keeps giving me an 'overflow' error after deleting the contents as desired.
P.S. I do not know how to attach files here so cannot provide the test data I'm using to run the code sorry..... Can anyone spot any problems in my code?
Thanks a lot in advance!
Ellen
I ran the code before on a spreadsheet with a number of lines. I basically want to remove any lines with the value in column C starting with 'M'. As there wouldn't be two blank rows in a row anywhere on the sheet apart from at the end of the filled range, I used the loop conditions below. So when there are two blank rows in a row, the loop should stop. However, for some reason this loop does not stop but keeps giving me an 'overflow' error after deleting the contents as desired.
P.S. I do not know how to attach files here so cannot provide the test data I'm using to run the code sorry..... Can anyone spot any problems in my code?
Thanks a lot in advance!
Ellen
Code:
Sub DeleteModel()
Dim i As Integer
i = 2
Sheets("sheet1").Select
Do While Cells(i, 3).Value <> "" & Cells(i + 1, 3).Value <> ""
If Cells(i, 3).Value Like "M*" Then
Call DeleteRow(i)
If Cells(i, 3).Value = "" Then
Call DeleteRow(i)
End If
Else
i = i + 1
End If
Loop
End Sub
Last edited by a moderator: