Help inserting row after text
Sub InsertRows()
Dim i As Integer
Const LastRow As Integer = 2500
With ActiveSheet.Range("A1")
For i = 1 To LastRow
If .Offset(i, 0).Value = "----" Then
.Offset(i + 2, 0).EntireRow.Insert
End If
Next i
End With
End Sub
you can change the value of the constant to suit yourself but, without
making the Sub fancy, the extra 500 allows for the rows that you
insert.
timwell wrote:
Hello,
I have a spreadsheet that I am trying to divide into sections with a
macro.
In column A, starting in cell A9 and going down, each section is
divided by 4 dashes("----").
I would like the macro to find the "----" and then move down 2 rows and
insert a row.
This would divide the section and its subtotals from the next section
of data.
The data can contain up to 2000 rows.
Thanks so much for any help.
Timwell
|