insert rows automatically

sbrown64

Board Regular
Joined
Aug 23, 2019
Messages
87
HiI have created a table & in column B I enter a number (i.e 3) is there a way to automatically add 2 rows below the line, so if the number was 5, it would add 4 rows below?RegardsStephen
 
Hi
someone just supplied this code to me and it worked, so i say thank you to all of your help.

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 9/14/2019 12:55:21 PM
Dim lst As ListObject
Dim lastRR As Range
Dim lngRR As Long
On Error GoTo Err_Worksheet_Change
Set lst = Me.ListObjects("Table2")
Set lastRR = lst.Range(lst.ListRows.Count + 1, 2)
If Target.Count = 1 And Not IsEmpty(Target) Then
Application.EnableEvents = False
If CLng(Target) > 0 Then
lngRR = CLng(Target) - 1
End If
If Not Intersect(Target, lastRR) Is Nothing Then
lst.Resize Me.Range(lst.Range.Resize(lst.Range.Rows.Count + lngRR).Address)
End If
End If
Exit_Worksheet_Change:
Application.EnableEvents = True
Exit Sub
Err_Worksheet_Change:
MsgBox Err.Description
Resume Exit_Worksheet_Change
End Sub

Regards
Stephen
[/FONT]
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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