Thread: Insert a Row
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Insert a Row

Hi
try the following macro.
Sub insert_rows()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.count, "A").End(xlUp).row
For row_index = lastrow - 1 To 1 Step -1
If lcase(Cells(row_index+1, "A").Value) ="sales" Then
Cells(row_index + 1, "A").resize(3,1).EntireRow.Insert _
(xlShiftDown)
End If
Next
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

"Matt B" schrieb im Newsbeitrag
m...
Hi,

Somewhere in column A, a cell contains the text "sales". Within a
macro I want to insert 3 rows above the row that has "sales" in it.

Is this possible?

TIA

Matt