Dave,
You could also simply insert an Exit Sub line in the If Then statement: for
your code -
If ActiveCell.Value = "TOTAL EXPENSES" Then
Selection.EntireRow.Insert
Exit Sub
End If
For the OP's code:
For Each c In [A1:A150]
If c Like "TOTAL EXPENSES" Then
c.EntireRow.Insert
Exit Sub
End If
Next
HTH,
Bernie
MS Excel MVP
"Dave O" wrote in message
oups.com...
Alternatively, since the report varies in length, you could enter the
word "stop" below the last row of the report and run that follows.
That will avoid the step of amending the code each time you run the
report.
Sub InsertRow()
Range("a1").Select
Do Until ActiveCell.Value = "stop"
If ActiveCell.Value = "TOTAL EXPENSES" Then
Selection.EntireRow.Insert
ActiveCell.Offset(1, 0).Select
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
|