I am using the following code to insert rows in two sheets at the same time. However I also want to copy down the formulas from the row above those inserted on the second sheet after the additional rows have been added. Any help would be much appreciated,
Sub insertRowsSheets()
'Disable Excel properties before macro runs
With Application
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
'Declare obiect variables
Dim ws As Worksheet, iCountRows As Integer
Dim activeSheet As Worksheet, activeRow As Long
Dim startSheet As String
'State activeRow
activeRow = ActiveCell.Row
'Save initial active sheet selection
startSheet = ThisWorkbook.activeSheet.Name
'Trigger input message to appear in terms of how many rows to insert
iCountRows = Application.InputBox(Prompt:="How many rows do you want to insert, starting with row" & activeRow & "?", Type:=1)
'Error handling end the macro it a zero, negative integer or non-integer value is entered
If iCountRows = False Or iCountRows <= 0 Then End
'Loop through the worksheets in Active Workbook
For Each ws In ActiveWorkbook.Sheets
ws.Activate
Rows(activeRow & ":" & activeRow + iCountRows - 1).Insert Shift:=xlDown
Next ws
'Move cursor back to intial worksheet
Worksheets(startSheet).Select
Range("A1").Select
'Re-enable Excel properties once macro is complete
With Application
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Sub insertRowsSheets()
'Disable Excel properties before macro runs
With Application
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
'Declare obiect variables
Dim ws As Worksheet, iCountRows As Integer
Dim activeSheet As Worksheet, activeRow As Long
Dim startSheet As String
'State activeRow
activeRow = ActiveCell.Row
'Save initial active sheet selection
startSheet = ThisWorkbook.activeSheet.Name
'Trigger input message to appear in terms of how many rows to insert
iCountRows = Application.InputBox(Prompt:="How many rows do you want to insert, starting with row" & activeRow & "?", Type:=1)
'Error handling end the macro it a zero, negative integer or non-integer value is entered
If iCountRows = False Or iCountRows <= 0 Then End
'Loop through the worksheets in Active Workbook
For Each ws In ActiveWorkbook.Sheets
ws.Activate
Rows(activeRow & ":" & activeRow + iCountRows - 1).Insert Shift:=xlDown
Next ws
'Move cursor back to intial worksheet
Worksheets(startSheet).Select
Range("A1").Select
'Re-enable Excel properties once macro is complete
With Application
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub