PDA

View Full Version : [SOLVED:] VBA To Insert A new Row with Specific formatting



simora
07-24-2021, 01:56 AM
I am trying to insert a new row into a worksheet, but after inserting the row,
I want to change the new Row Interior.ColorIndex = 0 for Columns H to S only.
I don't want to change the rest of the formatting.

How do I code this so that I don't change the rest of that Row.
This is how I'm inserting my new row.


ActiveCell.Offset(1).EntireRow.Insert

anish.ms
07-24-2021, 04:39 AM
may be


Intersect(Rows(ActiveCell.Offset(1).Row), Range("H:S")).Interior.ColorIndex = 0

simora
07-24-2021, 04:32 PM
anish.ms: Thanks
Unfortunately, that did not do the trick.
The code had no effect on the new inserted Row.
I will revisit it later.

Paul_Hossler
07-24-2021, 05:05 PM
ActiveCell.Offset(1).EntireRow.Insert
ActiveCell.Offset(1).EntireRow.Cells(1, 8).Resize(1, 12).Interior.ColorIndex = xlColorIndexNone

simora
07-24-2021, 08:04 PM
Thanks Paul_Hossler:


I did this clunky code to achieve the results that I was looking for once my brain got switched back on.



ActiveCell.Offset(1).EntireRow.Insert
Range("H" & ActiveCell.Offset(1, 0).Row & ":S" & ActiveCell.Offset(1, 0).Row).Interior.ColorIndex = 0


I will try your code anyway.


Thanks