I have a simple VBA Macro that basically copies cells from one Workbook to another. Now the thing is that another sheet was added to the Workbook where the macro runs. I simply would think that switching that Sheets(i).Select number to increase by one would do the trick. That turned out to simply not work. Any suggestion or help as to why this is happening would be greatly appreciated.
Sub BankerMacro()
'
' BankerMacro Macro
'
Dim sForecastFile, sUploadFile
Dim i As Integer
i = 8
Application.ScreenUpdating = False
sForecastFile = ActiveWorkbook.Name
Workbooks.Add
sUploadFile = ActiveWorkbook.Name
Range("A1") = "Company"
Range("B1") = "Department"
Range("C1") = "Location"
Range("D1") = "Account"
Range("E1") = "Intercompany"
Range("F1") = "Amount"
Range("G1") = "Fiscal Year"
Range("H1") = "Fiscal Month"
Range("I1") = "Scenario"
Range("J1") = "Reporting"
Range("K1") = "EndMarket"
Range("L1") = "Project"
Range("M1") = "Segment"
Range("A2").Select
Windows(sForecastFile).Activate
For i = 8 To 8
**Sheets(i).Select**
Range("AC5").Select
Do Until (Range("A" & ActiveCell.Row)) = "END"
If Range("BX" & ActiveCell.Row) <> "" Then
Range("BV" & ActiveCell.Row, "BY" & ActiveCell.Row).Copy
Windows(sUploadFile).Activate
Range(ActiveCell, ActiveCell.Offset(35, 0)).PasteSpecial xlPasteValues
Range("E" & ActiveCell.Row, "E" & ActiveCell.Row + 35) = "ICDefault"
Windows(sForecastFile).Activate
Range(ActiveCell, ActiveCell.Offset(0, 35)).Copy
Windows(sUploadFile).Activate
Range("F" & ActiveCell.Row).PasteSpecial xlPasteValues, , , True
Windows(sForecastFile).Activate
Range("AC1:BL2").Copy
Windows(sUploadFile).Activate
Range("G" & ActiveCell.Row).PasteSpecial xlPasteValues, , , True
Range("I" & ActiveCell.Row, "I" & ActiveCell.Row + 35) = sScenario
Range("J" & ActiveCell.Row, "J" & ActiveCell.Row + 35) = "G/L Data (CC)"
Windows(sForecastFile).Activate
Range("BZ" & ActiveCell.Row, "CB" & ActiveCell.Row).Copy
Windows(sUploadFile).Activate
Range("K" & ActiveCell.Row, "M" & ActiveCell.Row + 35).PasteSpecial xlPasteValues
Range("A1").End(xlDown).Offset(1, 0).Select
Windows(sForecastFile).Activate
End If
ActiveCell.Offset(1, 0).Select
Loop
Next i
Path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\"
Windows(sUploadFile).Activate
ActiveWorkbook.SaveAs Path & "Final File Banker"
Application.ScreenUpdating = True
End Sub
Please note the error occurs at Sheets(i).Select.