Link to home
Start Free TrialLog in
Avatar of cegeland
cegelandFlag for Norway

asked on

Macro: Inserting a new row, keep the formatting - change fill for one cell

Hi!
Attached I have a macro for inserting a new row into a spreadsheet. This works fine but I would like the macro to preset the cell i column K with a fill color (using RGB value). This fill color will later be changed by a macro running in Worksheet_change.

Thanks!


Sub InsertARow()
     'make new row
    ActiveCell.EntireRow.Insert shift:=xlUp
     'copy the row above
    ActiveCell.Offset(1, 0).EntireRow.Copy Cells(ActiveCell.Row, 1)
    On Error Resume Next
     'clear every cell in the new line that does not have a formula
    ActiveCell.EntireRow.SpecialCells(xlCellTypeConstants, 23).ClearContents
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of philip m o'brien
philip m o'brien
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial