Run-Time Error '13' Type Mismatch

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
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
The line where your crashing is trying to open a file, if that file isn't in that location that is probably your problem.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top