Fix Excel VBA References to a Range in Another Open Workbook
Question details
The user needs to reference a range on a named worksheet in another open workbook and search it with VBA Find.

- Product
- Microsoft Excel VBA
- Device & OS
- not provided
- Scenario
- A macro searches a worksheet in a different workbook that is already open.
- Observed behavior
- The Find operation works in the current workbook, but the cross-workbook reference returns a Subscript out of range error.
Open the target workbook in the same Excel instance as the macro and note its file name and worksheet name. In Excel, press Alt+F11 to open the VBA editor.
Correct the Workbook Name and Worksheet Reference
Use this fix when the Workbooks collection cannot find the target file or worksheet.
For an already open workbook, use its file name with the extension, not its folder path. A typo such as .xlms instead of .xlsm can cause a Subscript out of range error.
In the VBA editor, open View > Immediate Window, type ? strWorkBook, and press Enter. Compare the result with the target workbook's exact file name, including its extension.
In the Immediate window, run For Each wb In Application.Workbooks: Debug.Print wb.Name: Next wb. Use the displayed name to correct strWorkBook if necessary.
In Excel, check the target sheet tab, then confirm that the string in Worksheets("SheetName") matches that tab name, including spaces.
In the VBA editor, correct the workbook and sheet names, then run the macro with F5. For example: Set ws = Workbooks("Report.xlsm").Worksheets("Sheet1"), followed by Set found = ws.Range("A:A").Find(What:="example", LookIn:=xlValues, LookAt:=xlWhole).
After the Find call, test If found Is Nothing Then before using the result; Find returns Nothing when it does not locate a match.

Work With Excel Files in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday workbook tasks. It does not fix Excel's VBA reference error; check macro compatibility separately before migrating VBA-dependent workbooks.

Frequently Asked Questions
Do I need the full file path to reference an open workbook?
No. Use the workbook's name, including its extension, in Workbooks("Report.xlsm"). The workbook must be open in the Excel instance running the macro.
How can I see the names Excel uses for open workbooks?
Press Alt+F11, open View > Immediate Window, and run For Each wb In Application.Workbooks: Debug.Print wb.Name: Next wb. Compare the printed names with your workbook reference.
Can a worksheet name cause the same error?
Yes. Check the sheet tab in the target workbook and make sure the name inside Worksheets("SheetName") matches it, including spaces.
What happens if Find does not find the search value?
Find returns Nothing. Check If found Is Nothing Then before accessing properties such as found.Address.




