S
Steve
Hi everyone. I have some code below that is (or supposed) to insert a
number of rows (based on an input from the user) on several sheets
included in the array, and then copy the formulas from the row abover
and copy intot he newly created rows. All works great on the firt
sheet (named Data). BUT, the code does not insert rows or copy
formulas in any of the other sheets in the array. Any ideas what I'm
doing wrong?? Thanks!!
Sub New_Project()
Dim ws As Worksheet
Dim x As Integer
x = InputBox("How many rows do you want to insert?")
For Each ws In Worksheets
ws.Visible = xlSheetVisible
Next
Range("B5000").End(xlUp).Select
Sheets(Array("Data", "Sheet1", "Sheet2", Sheet3", "Sheet4")).Select
Sheets("Data").Activate
ActiveCell.Offset(1, 0).Resize(x, 1).EntireRow.Insert
ActiveCell.Offset(-2 - x, 0).Select
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1, 0).Resize(x, 1).EntireRow.PasteSpecial
Paste:=xlFormulas
Application.CutCopyMode = False
Selection.End(xlToLeft).Select
Sheets("Data").Select
Sheets("Data").Range("B5000").End(xlUp).Offset(1, -1).Resize(x,
36).ClearContents
Sheets("Data").Select
End Sub
number of rows (based on an input from the user) on several sheets
included in the array, and then copy the formulas from the row abover
and copy intot he newly created rows. All works great on the firt
sheet (named Data). BUT, the code does not insert rows or copy
formulas in any of the other sheets in the array. Any ideas what I'm
doing wrong?? Thanks!!
Sub New_Project()
Dim ws As Worksheet
Dim x As Integer
x = InputBox("How many rows do you want to insert?")
For Each ws In Worksheets
ws.Visible = xlSheetVisible
Next
Range("B5000").End(xlUp).Select
Sheets(Array("Data", "Sheet1", "Sheet2", Sheet3", "Sheet4")).Select
Sheets("Data").Activate
ActiveCell.Offset(1, 0).Resize(x, 1).EntireRow.Insert
ActiveCell.Offset(-2 - x, 0).Select
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1, 0).Resize(x, 1).EntireRow.PasteSpecial
Paste:=xlFormulas
Application.CutCopyMode = False
Selection.End(xlToLeft).Select
Sheets("Data").Select
Sheets("Data").Range("B5000").End(xlUp).Offset(1, -1).Resize(x,
36).ClearContents
Sheets("Data").Select
End Sub