*SOLVED* subscript out of range error
I have made a macro for copy and paste into a new file.
Copied it into vba editor into my code.
Worked fine, but not anymore.
It makes a new file but as soon as it wants to go back to
"Windows("file.xls").Activate"
"it gives a suscripts out of range" error
I have checked for the value of "strBestandMap"
and "strBestand" both are not changed and are fine.
This is my code:
VB Code:
Workbooks.Add
ChDir strBestandMap
ActiveWorkbook.SaveAs Filename:=strBestand
Windows("file.xls").Activate
Sheets("resultaten").Select
Cells.Select
Selection.Copy
Windows("" & strBestandNaam & "").Activate
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
Thanks in advance,
Brian
Sorry it has taken so long but NO
Converting SaveAs to SaveCopyAs has not helped at all.
VB Code:
Workbooks.Add
ChDir strBestandMap
ActiveWorkbook.SaveAs Filename:=strBestand
Workbooks("file.xls").Activate
Sheets("resultaten").Select
Cells.Select
Selection.Copy
Workbooks("" & strBestandNaam & "").Activate
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
The programs stops at:
Workbooks("Royaltys.xls").Activate
And gives a "Subscript out of range" error
It has worked before I have made some changes to the code somewhere else in the program (nothing to do with this)
and now it doesn't work.
HELP SOMEBODY HELP,
Thanks in advance,
Brian