insert row within function

C

c_sports

I need a formula that would insert a blank row above the row that contains a
specific value. ie, if a cell contains "x", insert a blank row above it.

Or, the same in a macro.

Thanks,

chris
 
C

CLR

Here's a macro someone gave me........it will look for the word "Total" in
either column 3 (C) or column 8 (H) and if found will BOLD the text in that
row and add a blank row .....

Sub AddRows()
'Adds blank rows to the sheet for easier reading
'Also changes font on the first 30 columns from the left to BOLD
Dim lastrow As Long
Dim r As Long
lastrow = Range("x" & Rows.Count).End(xlUp).Row
For r = lastrow To 2 Step -1
If InStr(1, Cells(r, 3).Value, "Total") > 0 Or _
InStr(1, Cells(r, 8).Value, "Total") > 0 Then
Range(Cells(r, 1), Cells(r, 30)).Font.Bold = True '30 is number
'of columns from "A" that the macro will BOLD
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub


it can be run multiple times for more blank rows..........you can modify it
to fit your purposes........

hth
Vaya con Dios,
Chuck, CABGx3
 

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

Top