Hi,
I have an excel workbook containing 50 worksheets. The names are "Scenario51", "Scenario52"...."Scenario100". Each worksheet contain the same number of data and same format, column/row numbers. All I want to do is write an macro to copy those data from each sheet (from B2 to AA32 in each sheet) and paste transpose to a new worksheet (already created in this workbook called "99AA") from top to bottom and each separate by 6 rows high. My coding is:
-------------------------------------------------------------------------------
Sub Test()
Dim Start As Long
Dim Sht As String
For Start = 51 To 100 Step 1
nwRow = (Start - 51) * 26 + 6 * (Start - 51)
Sht = "Scenario" & Start
Worksheets("Sht").Activate
ActiveSheet.Range("B2:AA32").Copy
Worksheets("99AA").Range("D2").Offset(nwRow, 0).PasteSpecial xlPasteValues, Transpose:=True
Next Start
End
End Sub
---------------------------------------------------------
It shows an runtime error 9" subscript out of range. I suspect it might be the incorrect way using the variable to loop through different worksheets? Appreciate for any insights.
Bookmarks