Inserting a row when a value is entered

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need code for the following:

If I enter a value in a2 , a row is inserted below

Thanks for any assistance
 
Use this sheet event code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count = 1 Then
Target.Offset(1).EntireRow.Insert xlShiftDown
End If
End Sub
 
You haven't tested A2 Rob.

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Address = "$A$2" Then
.Offset(1).EntireRow.Insert xlShiftDown
End If
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks Bob - very helpful

Bob Phillips said:
You haven't tested A2 Rob.

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Address = "$A$2" Then
.Offset(1).EntireRow.Insert xlShiftDown
End If
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top