C
Craig
I'm using Excel XP. I can't seem to get the following
code to work. The following code deletes any blank row,
and then moves to the next row and checks if it's blank,
too. If it is, the row is deleted. If not, the row is
skipped, etc.
The problem I run into is that after the text that I want
has had all the blank rows removed, the code will continue
executing indefinitely. I need the code to STOP after it
has completed deleting the blank rows from my block of
text.
What I'm trying to do below is set a counter ('y') so that
if 25 consecutive rows are blank, then the code will know
that the end of the text has come and it's time to end the
macro. But the line "y = y + 1" generates the error "code
execution has been interrupted." Any thoughts?
Sub DeleteRows()
Dim y As Long
y = 0
Do While y <> 25
If ActiveCell.Value = "" Then
Selection.EntireRow.Delete
y = y + 1
Else
ActiveCell.Offset(rowOffset:=1,
columnOffset:=0).Activate
y = 0
End If
Loop
End Sub
Thanks.
C.
code to work. The following code deletes any blank row,
and then moves to the next row and checks if it's blank,
too. If it is, the row is deleted. If not, the row is
skipped, etc.
The problem I run into is that after the text that I want
has had all the blank rows removed, the code will continue
executing indefinitely. I need the code to STOP after it
has completed deleting the blank rows from my block of
text.
What I'm trying to do below is set a counter ('y') so that
if 25 consecutive rows are blank, then the code will know
that the end of the text has come and it's time to end the
macro. But the line "y = y + 1" generates the error "code
execution has been interrupted." Any thoughts?
Sub DeleteRows()
Dim y As Long
y = 0
Do While y <> 25
If ActiveCell.Value = "" Then
Selection.EntireRow.Delete
y = y + 1
Else
ActiveCell.Offset(rowOffset:=1,
columnOffset:=0).Activate
y = 0
End If
Loop
End Sub
Thanks.
C.