Insert rows across all worksheets

Hnk927

New Member
Joined
Dec 29, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I’m very inexperienced at vba and looking for some help.

I have a worksheet with 28 tabs. I’d like to insert a row on the first tab and have the action repeated across all other tabs. At the sam time, I would like to duplicate the formulas from a set range in the preceding row into this new row across all tabs.

I would also like the ability to delete a row in the first tab and have the action automatically duplicated across all other tabs

I’ve seen similar stuff but could not figure it to my situation. Thanks in advance for any help.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
While holding the "Shift button down", click the first and the last sheet tab. All tabs are now highlighted.
You can now insert or delete rows, the action will be repeated on all sheets
To duplicate formulas use Excel tables
 
Upvote 0
Hi
VBA?
Try
VBA Code:
Sub test()
Dim i As Long
Dim x As String
Dim z As Variant
    For i = 1 To Sheets.Count
        x = x & """" & Sheets(i).Name & """" & ","
    Next
    z = Split(Mid(Left(x, Len(x) - 2), 2), """,""")
    Sheets(z).Select
    Sheets("Sheet1").Rows("1:4").Insert Shift:=xlDown
End Sub
 
Upvote 0
Hi
VBA?
Try
VBA Code:
Sub test()
Dim i As Long
Dim x As String
Dim z As Variant
    For i = 1 To Sheets.Count
        x = x & """" & Sheets(i).Name & """" & ","
    Next
    z = Split(Mid(Left(x, Len(x) - 2), 2), """,""")
    Sheets(z).Select
    Sheets("Sheet1").Rows("1:4").Insert Shift:=xlDown
End Sub
I copy an pasted but it did not work. Perhaps I am doing something wrong.
 
Upvote 0
While holding the "Shift button down", click the first and the last sheet tab. All tabs are now highlighted.
You can now insert or delete rows, the action will be repeated on all sheets
To duplicate formulas use Excel tables
Thanks for your reply. I was aware of this method, but am looking for a quick way of doing this where I can choose a row on my first sheet, insert a row and have this simultaneously happen in the same place over the other sheets. Then have the formulas from Columns R through AD from above row copied into new row across all sheets.
 
Upvote 0
If I use the macro recorder to accomplish what I want to do, it produces the following which works. However, I'd like to modify it to have the macro apply to all sheets within the workbook without having them named within the macro, as I may change the names of the individual sheets. Currently as it is recorded, if I change a sheet name, then the macro does not work as intended. I am not really familiar with VBA but essentially want an 'Apply to all sheets'. I appreciate any clear help. Thanks.

VBA Code:
Sub Insert_New_Row()
'
' Insert_New_Row Macro
'
' Keyboard Shortcut: Ctrl+i
'

Sheets(Array("Parameters", "Summary", "Pay Period 1", "Pay Period 2", _
        "Pay Period 3", "Pay Period 4", "Pay Period 5", "Pay Period 6", "Pay Period 7", _
        "Pay Period 8", "Pay Period 9", "Pay Period 10", "Pay Period 11", "Pay Period 12", _
        "Pay Period 13", "Pay Period 14", "Pay Period 15", "Pay Period 16", "Pay Period 17" _
        , "Pay Period 18", "Pay Period 19", "Pay Period 20", "Pay Period 21", _
        "Pay Period 22", "Pay Period 23")).Select
    Sheets("Parameters").Activate
    Sheets(Array("Pay Period 24", "Pay Period 25", "Pay Period 26")).Select Replace _
        :=False
    Rows(ActiveCell.Row).Select
    Selection.Copy
    Rows(ActiveCell.Row).Select
    Selection.Insert Shift:=xlDown
    Sheets("Parameters").Select

Exit Sub

End Sub
 
Last edited by a moderator:
Upvote 0
Hi,
Try
VBA Code:
Sub Insert_New_Row()
'
' Insert_New_Row Macro
'
' Keyboard Shortcut: Ctrl+i
'

    Dim i As Long
    Dim x As String
    Dim z As Variant
    For i = 1 To Sheets.Count
        x = x & """" & Sheets(i).Name & """" & ","
    Next
    z = Split(Mid(Left(x, Len(x) - 2), 2), """,""")
    Sheets(z).Select
    Sheets("Parameters").Activate
    Sheets(Array("Pay Period 24", "Pay Period 25", "Pay Period 26")).Select Replace _
                                                                            :=False
    Rows(ActiveCell.Row).Select
    Selection.Copy
    Rows(ActiveCell.Row).Select
    Selection.Insert Shift:=xlDown
    Sheets("Parameters").Select
End Sub
 
Upvote 0
Solution
Hi,
Try
VBA Code:
Sub Insert_New_Row()
'
' Insert_New_Row Macro
'
' Keyboard Shortcut: Ctrl+i
'

    Dim i As Long
    Dim x As String
    Dim z As Variant
    For i = 1 To Sheets.Count
        x = x & """" & Sheets(i).Name & """" & ","
    Next
    z = Split(Mid(Left(x, Len(x) - 2), 2), """,""")
    Sheets(z).Select
    Sheets("Parameters").Activate
    Sheets(Array("Pay Period 24", "Pay Period 25", "Pay Period 26")).Select Replace _
                                                                            :=False
    Rows(ActiveCell.Row).Select
    Selection.Copy
    Rows(ActiveCell.Row).Select
    Selection.Insert Shift:=xlDown
    Sheets("Parameters").Select
End Sub
Thanks, but only inserted a row on first sheet.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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