Hi,
I have a macro which runs a routine on a number of files. I wrote it in Excel 2013 and have been using it successfully on that version for close to a year.
However, today I tried to run it on a different computer which has Excel 2010. For some reason when the macro opens a workbook, the code which references the open workbook now causes a Subscript out of Range (Error 9) break.
For example, this works in Excel 2013 without issue but breaks in 2010 (on the Do line), as the program can't seem to find the specified workbook (even though it just opened it):
I tested a few ideas and discovered that adding the file extension to the code does work in Excel 2010.
The weird thing is I have been using Excel/VBA for 12 years and have never had to refer to a workbook using its file extension.
Has anyone encountered this before? Any ideas for an easy fix? I'd rather not have to add & ".xlsx" to every workbook reference!
Thank you for your consideration.
I have a macro which runs a routine on a number of files. I wrote it in Excel 2013 and have been using it successfully on that version for close to a year.
However, today I tried to run it on a different computer which has Excel 2010. For some reason when the macro opens a workbook, the code which references the open workbook now causes a Subscript out of Range (Error 9) break.
For example, this works in Excel 2013 without issue but breaks in 2010 (on the Do line), as the program can't seem to find the specified workbook (even though it just opened it):
Code:
Current_Name = "ABC"
Do Until Workbooks(Current_Name).Sheets("Table").Cells(Calc_Row, Date_Col).Value = ""
Calc_Row = Calc_Row + 1
Loop
I tested a few ideas and discovered that adding the file extension to the code does work in Excel 2010.
Code:
Workbooks(Current_Name & ".xlsx")
The weird thing is I have been using Excel/VBA for 12 years and have never had to refer to a workbook using its file extension.
Has anyone encountered this before? Any ideas for an easy fix? I'd rather not have to add & ".xlsx" to every workbook reference!
Thank you for your consideration.