Insert Macro

Hello,

I want to write a macro where on inserting a new row in the active worksheet, the newly inserted row will become yellow in color. But I dont know how to do this. kindly help

Thanks




Answer this question

Insert Macro

  • Cryo75

    Hi

    In order to run your macro it needs to be triggered by an event. I don't think that there is an event generated by inserting a row.


  • Poma

    There is no event handler for inserting a row.

    However, you can add a row and turn the background color to yellow with VBA.

    For example

    Sub X()
    Dim rngCurrent As Range
    Set rngCurrent = ActiveCell

    rngCurrent.Insert (xlShiftDown)
    With ActiveSheet.Rows(rngCurrent.Row & ":" & rngCurrent.Row).Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    End Sub



  • Insert Macro