Insert row above rows containing certain information

afterdinnerspeaker

Board Regular
Joined
Jan 10, 2019
Messages
70
I posted this to Excel Forum earlier today but unable to get Macro to work satisfactorily...please HELP!

Hi there folks!

Just wondering if anyone could help me with the following tasks:

• Insert one row above each row containing a “number” in column “C”
• Insert one row above each of the two rows containing headings “TOTAL REVENUE” and “TOTAL EXPENSE” in column “B”
• Highlight the two instances of the one word headings “REVENUE” and “EXPENSE” (currently but not always in row #3 and row #13 ) in “light green”
PLEASE NOTE: The words "REVENUE" & "EXPENSE" span both column B & C in their respective rows


I attached a sample of the spreadsheet.

Many thanks in advance,

Jerry
<fieldset class="postcontent"><legend>
paperclip.png
Attached Files</legend>
</fieldset>
 
Last edited:
Try

S
Code:
ub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "B").End(xlUp).Row
For r = lr To 3 Step -1
    If Len(Range("C" & r)) = 4 Or Range("B" & r).Value = "TOTAL REVENUE" Or Range("B" & r).Value = "TOTAL EXPENSE" Then
        Rows(r).Font.Bold = True
        Rows(r).Insert
    End If
    If Range("B" & r).Value = "REVENUE" Or Range("B" & r).Value = "EXPENSE" Then
        With Range("B" & r & ":C" & r).Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 5296274
        End With
    End If
Next r
End Sub
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Works perfectly...as usual!

Thank you so much again Michael for your expertise (and patience).

Regards from the other side of the world,

Jerry
 
Upvote 0

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top