View Single Post
  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Debi,

Step up through the rows from the bottom:

For myRow = 150 To 1 Step -1
If Cells(myRow, 1).Value Like "TOTAL EXPENSES" Then
Cells(myRow, 1).EntireRow.Insert
End If
Next myRow

HTH,
Bernie
MS Excel MVP

"Debi" wrote in message
...
When I use the following code in an Excel macro to insert a row, it does

not
work correctly. Instead of inserting just one row above the TOTAL

EXPENSES
row, rows will continue to be inserted until the worksheet runs out of

rows.
Could someone please help me.

For Each c In [A1:A150]
If c Like "TOTAL EXPENSES" Then
c.Activate
ActiveCell.EntireRow.Insert
End If
Next

I have to use the "TOTAL EXPENSES" instead of the row number because this

is
a report I import from another program and the row number that TOTAL

EXPENSES
appears in varies from report to report depending on how many expenses are

in
each report.
Thanks