Solved Macro To Insert Row Based on Input

June 18, 2015 at 15:03:26
Specs: Windows 10
Within a macro, I am trying to figure out how to insert a row based on the input of a value in a cell. If cell N2 = Y, then I want a row inserted directly below.

See More: Macro To Insert Row Based on Input

Report •

June 18, 2015 at 19:13:00
Thanks for letting us know what you are trying to do.

If you want some help with that, just ask.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

June 19, 2015 at 08:00:32
I would appreciate help. What VBA code would I need for my macro?

Report •

June 19, 2015 at 11:56:00
✔ Best Answer
Right Click the sheet tab for the sheet you want this to happen in and choose View Code. Paste this code into the window that opens.

Private Sub Worksheet_Change(ByVal Target As Range)
'Determine if a Y was entered into N2
 If Target.Address = "$N$2" Then
  If Target = "Y" Then
'If Yes, then Disable Events, Insert a Row and Re-enable Events
    Application.EnableEvents = False
     Rows(Target.Row + 1).EntireRow.Insert
    Application.EnableEvents = True
  End If
 End If
End Sub

After that, refer to this link for a quick VBA tutorial. If you are going to be using macros, you should familiarize yourself with how to troubleshoot them.

message edited by DerbyDad03

Report •

Related Solutions

June 19, 2015 at 12:32:02
That worked! Thank you for your time and help!

Report •

Ask Question