Add row to table using vba

Sashi7070

New Member
Joined
Oct 11, 2018
Messages
2
Hello, I am looking for help, I am really new to vba. My problem is that, lets say I have 4 tables in the active sheet, I want to making coding so that, if I add any number of rows to the 1st table, I want the same number of rows to be added at the below 3 tables automatically. For example, I add 2 rows to the 1st table, so the 2nd, 3rd and 4th tables also must automatically generate 2 rows. So far I create coding to add number of rows for the 1st table only, I hope someone can help me solve this, thank...

Sub InsertNumRows()

ActiveCell.EntireRow.Copy

Dim Rng As Long

Application.DisplayAlerts = False
On Error Resume Next
Rng = InputBox("Enter number of rows required.")
On Error GoTo 0
Application.DisplayAlerts = True

If Rng = 0 Then
MsgBox "You didn't specify a range!"
Exit Sub

Else
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(Rng, 0)).Select
Selection.EntireRow.Insert Shift:=xlDown
End If

End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hello and welcome.

I don't think we have enough information.

Your code copies the active row, then reproduces them 'Rng' number of times.

How do you determine where in the other tables to insert the rows?

What range determines these tables?

Do you want the same information copied in table 1 to appear in table 2?

Are your tables excel tables or just designated ranges formatted into a table?
 
Upvote 0
Hello, actually what I want is, for example all my four table have 1 row initially, so when i copy data from 1st row and inserted it to second row, I want the other table also do the same thing automatically, copy data from its own table and paste it to the next row. By the way, my tables are not excel tables.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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