Search for subtotals

T

Teak

I wld like to start at cell D3. Then search for any subtotals downwards.
If found, say cell D15, outline the upper border (ie btw D14 & D15),
and insert a line below D15 (I find this difficult becos inserted line is
always above, not below)

This should continue until end of data rows.

Thanks.
 
F

Frank Kabel

Hi
try the following macro. It tests column A and inserts a blank row if
the word 'subtotal' is found
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 InStr(Cells(row_index, "A").Value,"Subtotal")>0 then
Cells(row_index + 1, "A").EntireRow.Insert (xlShiftDown)
End If
Next
End Sub
 
Top