Insert New Row VBA Macro

Snuffle

New Member
Joined
Oct 28, 2016
Messages
2
Hello

I am trying to insert a new sheet row using VBA and then change the Interior.ColorIndex of specific cells in the new row.

I am using ActiveCell.Offset(1).EntireRow.Insert to insert a new row below the active cell, but I am unsure how to change the background color of specific cells in the new row.

For example:

If I inserted a new row (i.e. row 4) I would like the background color of cell A4 to be white and the background color of cell B4 and C4 to be grey.

Any help would be most appreciated!

Regards

Martin
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hello

I am trying to insert a new sheet row using VBA and then change the Interior.ColorIndex of specific cells in the new row.

I am using ActiveCell.Offset(1).EntireRow.Insert to insert a new row below the active cell, but I am unsure how to change the background color of specific cells in the new row.

For example:

If I inserted a new row (i.e. row 4) I would like the background color of cell A4 to be white and the background color of cell B4 and C4 to be grey.

Any help would be most appreciated!

Regards

Martin

this will do your example

Code:
ActiveSheet.Cells(4, 1).EntireRow.Insert
With ActiveSheet.Range(ActiveSheet.Cells(4, 2), activeshet.Cells(4, 3))
    .ThemeColor = xlThemeColorDark1
    .TintAndShade = -0.249977111117893
End With

The best way to do interior cell or font coloring is to record the macro.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,878
Messages
6,122,062
Members
449,064
Latest member
scottdog129

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