macro to insert row above

girl81

New Member
Joined
Apr 19, 2012
Messages
9
Hello! Awesome Site by the way :)

I need to create a macro that will do the following....

When value entered into Column A Sheet2, insert row above. The cell in column A that is now inserted should read "subtotal" (In Bold, caps)

Thanks In advance!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
    Application.EnableEvents = False
    With Target
        .EntireRow.Insert
        .Offset(-1).Value = "SUBTOTAL"
        .Offset(-1).Font.Bold = True
    End With
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Thanks!!

Can we add...

If value reads subtotal in column A; sum totals in column H from (if there is a value in coulmn A down to where the value reads subtotal) this same sum to happen in column M and O as well...
I would also like to sum rows H+M+O in coulmn R (easy formula already inserted) but, when new row is inserted via macro, I would like this formaula to be in column r.

tricky to explain.

Hope you can help.
 
Upvote 0

Forum statistics

Threads
1,215,713
Messages
6,126,412
Members
449,314
Latest member
MrSabo83

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