VBA & Macro Problems

Fix Excel VBA References to a Range in Another Open Workbook

Algirdas JasaitisAlgirdas Jasaitis Nov 27, 2026 869 views

Question details

The user needs to reference a range on a named worksheet in another open workbook and search it with VBA Find.

Fix an Excel VBA Range Reference to Another Open Workbook
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.
Before you start

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.

Solution 1Recommended

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.

1
Check the workbook variable

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.

2
List open workbook names

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.

3
Check the worksheet name

In Excel, check the target sheet tab, then confirm that the string in Worksheets("SheetName") matches that tab name, including spaces.

4
Update and test the reference

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).

5
Handle a missing match

After the Find call, test If found Is Nothing Then before using the result; Find returns Nothing when it does not locate a match.

Correct the Workbook Name and Worksheet Reference
Activation is not required: A qualified Workbooks(...).Worksheets(...).Range(...) reference can search the target workbook without activating it.
Free Microsoft Office alternative

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.

Open and work with spreadsheet data in a familiar interfaceCompatible with common Microsoft Excel formats, including XLSX and XLSFind data in worksheets without writing a VBA searchFree and lightweight for everyday office tasks
microsoft office alternative - wps office

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.