View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Elaine Elaine is offline
external usenet poster
 
Posts: 106
Default Insert Rows after word total

Peter, one other thing. I don't see an offset or some other command so that
if Total is on one line and Grand Total is in the next, then lines will not
be inserted.

Thanks.

"Peter T" wrote:

Hi Elaine,

Dim RngCell As Range
Dim rCell As Long
'code
If InStr(1, LCase(RngCell.Value), "total") 0 Then
If InStr(1, LCase(RngCell.Value), "grand total") = 0 Then
Rows(rCell + 1 & ":" & rCell + 2).Insert
End If
End If

could also AND the two conditions

Regards,
Peter T

"Elaine" wrote in message
...
I would like to insert two rows after the word Total appears in Column A
except at the bottom of the working range as I don't want to insert lines
between Total and Grand Total.

Dim RngCell as Range
Dim rCell as Long
If InStr(1, LCase(RngCell.Value), "total") 0 then
Rows(rCell + 1 & ":" & rCell + 2).Insert

How do I tell the above code not to insert two rows if Grand Total (with a
space) appears in the row below total?

Thanks for your help.

--Elaine