Automatically insert row below cell when text is written in.

nickstar76

New Member
Joined
Mar 17, 2011
Messages
11
Hey there

I know a little about Macro's but i have not been able to find the details online so far. What I want is for any information that is entered into column J for that to automatically insert a row underneath that row. The main problem i seem to be having is I can find a macro but you obviously need to click on tools>macro>run macro which goes against the whole point of it being automatic. The rows involved are 3:500.
 
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2:A100")) Is Nothing Then
    With Target(1, 7)
        .Value = Date
        .EntireColumn.AutoFit
    End With
ElseIf Target.Column = 10 Then
    If Target.Value <> "" And Target.Offset(1) <> "" Then Target.Offset(1).EntireRow.Insert
End If
End Sub
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2:A100")) Is Nothing Then
    With Target(1, 7)
        .Value = Date
        .EntireColumn.AutoFit
    End With
ElseIf Target.Column = 10 Then
    If Target.Value <> "" And Target.Offset(1) <> "" Then Target.Offset(1).EntireRow.Insert
End If
End Sub

Now it seems that the code is not working anymore. No error messages or anything just when entering data in that cell nothing happens.
 
Upvote 0
It is working here. Perhaps events are disabled. In the code window press CTRL + G to open the Immediate Window, type in

Application.EnableEvents=True

and press Enter. Then try entering data in column J.
 
Upvote 0
It is working here. Perhaps events are disabled. In the code window press CTRL + G to open the Immediate Window, type in

Application.EnableEvents=True

and press Enter. Then try entering data in column J.

I have entered that data but still nothing is working. If i go back to your old code that still works.
 
Last edited:
Upvote 0
Tried that and still nothing. I would usually be very happy with the previous code but I can see people I work with accidently hitting that tab and entering in row after row and they don't know how to delete them.
 
Upvote 0
This should fix it

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2:A100")) Is Nothing Then
    With Target(1, 7)
        .Value = Date
        .EntireColumn.AutoFit
    End With
ElseIf Target.Column = 10 Then
    If Target.Value <> "" And Target.Offset(1, -8).Value <> "" Then Target.Offset(1).EntireRow.Insert
End If
End Sub
 
Upvote 0
This should fix it

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2:A100")) Is Nothing Then
    With Target(1, 7)
        .Value = Date
        .EntireColumn.AutoFit
    End With
ElseIf Target.Column = 10 Then
    If Target.Value <> "" And Target.Offset(1, -8).Value <> "" Then Target.Offset(1).EntireRow.Insert
End If
End Sub

Awesome work thank you so much now all I just need to change it to the column L now how would I do that.
 
Upvote 0

Forum statistics

Threads
1,215,281
Messages
6,124,043
Members
449,139
Latest member
sramesh1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top