trentroach
New Member
- Joined
- Jan 18, 2013
- Messages
- 2
I'm getting an error message when running my macro. I'm just trying to open files and paste values part of a sheet into my sheet with the macro. About halfway through running it is when I get my error. The error is showing up on the line with red text. Thank you for your help.
Dim Dept
Dim I As Integer
Dept = Array("x", "101088", "101190", "101311", "101338", "101340" _
, "101342", "101344", "101346", "101351", "101355", "101357" _
, "101360", "101390", "101391", "101393", "101394", "101395" _
, "101402", "101403", "101414", "101416", "101430", "101431" _
, "101432", "101433", "101434", "101435", "101436", "101440" _
, "101441", "101442", "101443", "101444", "101445", "101450", _
, "101455", "101456", "101510", "101511", "101512", "101513", _
, "101514", "101603", "101671", "101673", "104638", "104646", _
, "104649", "104680", "105335", "105350", "105353", _
, "105356", "105358", "101675")
For I = 1 To 59
' open workbook to work in
Workbooks.Open Filename:="K:\Finance\FP&A\4. Forecast\SG&A\2013\Current Forecast\" & Dept(I) & ".xlsm"
'Which worksheet to work with
Worksheets("Current Forecast").Activate
'Select range to copy and switch to other workbook
Range("A8:O156").Select
Selection.Copy
ActiveWindow.ActivateNext
Application.Goto Reference:="soe_" & Dept(I)
Selection.PasteSpecial Paste:=xlValues
'select other workbook, deactivate copy mode and close workbook
ActiveWindow.ActivateNext
Application.CutCopyMode = False
ActiveWorkbook.Close SaveChanges:=False
Next I
Dim Dept
Dim I As Integer
Dept = Array("x", "101088", "101190", "101311", "101338", "101340" _
, "101342", "101344", "101346", "101351", "101355", "101357" _
, "101360", "101390", "101391", "101393", "101394", "101395" _
, "101402", "101403", "101414", "101416", "101430", "101431" _
, "101432", "101433", "101434", "101435", "101436", "101440" _
, "101441", "101442", "101443", "101444", "101445", "101450", _
, "101455", "101456", "101510", "101511", "101512", "101513", _
, "101514", "101603", "101671", "101673", "104638", "104646", _
, "104649", "104680", "105335", "105350", "105353", _
, "105356", "105358", "101675")
For I = 1 To 59
' open workbook to work in
Workbooks.Open Filename:="K:\Finance\FP&A\4. Forecast\SG&A\2013\Current Forecast\" & Dept(I) & ".xlsm"
'Which worksheet to work with
Worksheets("Current Forecast").Activate
'Select range to copy and switch to other workbook
Range("A8:O156").Select
Selection.Copy
ActiveWindow.ActivateNext
Application.Goto Reference:="soe_" & Dept(I)
Selection.PasteSpecial Paste:=xlValues
'select other workbook, deactivate copy mode and close workbook
ActiveWindow.ActivateNext
Application.CutCopyMode = False
ActiveWorkbook.Close SaveChanges:=False
Next I