Search for subtotals

  • Thread starter Thread starter Teak
  • Start date Start date
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top