A VBA function that reads a cell from a closed workbook fails for two separate reasons. First, the variable contains text, not a worksheet range. Second, even corrected VBA methods cannot perform this type of external read when called as a worksheet function. This affects operators who consolidate values from monthly files such as Nov.xlsx.
The problem
The issue came up in the Stack Overflow community when a Private Function named GetCellTest returned #VALUE! before displaying its second MsgBox. The relevant code stores an external address in a String variable, then tries to read CellPath.Value.How to get the cell value from a linked worksheet
A VBA String is only text. It does not represent a cell and therefore has no .Value property. VBA raises an “Object required” error at that line.
When a user-defined function, or UDF, runs from an Excel cell, VBA often does not display that error in a message box. The function stops, and Excel shows #VALUE! instead. Calling the same logic from a Sub procedure usually exposes the actual error.
Changing the line to Range(CellPath).Value does not solve the closed-workbook problem. Range can work with an external workbook when Excel has it open, but it does not provide a reliable way to read a cell from a workbook that remains closed.
The solution
For a value in a closed workbook, use one of two approaches.
The simplest option is a direct external reference in an Excel formula:
='C:\Path\To\[Nov.xlsx]Sheet1'!A1
This uses an A1 reference, where A1 identifies the column and row. Excel can maintain this link while Nov.xlsx is closed.
Do not construct this reference with INDIRECT. INDIRECT converts text into a reference, but it requires the referenced workbook to be open. It is therefore a poor fit for a monthly reporting process that reads files stored on the C:\ drive while those files remain closed.
The VBA option is ExecuteExcel4Macro. Despite its old name, it can retrieve a value from a closed workbook when run from a Sub procedure. It uses an R1C1 reference instead of A1 notation. In R1C1 notation, R1C1 means row 1, column 1, which is the same cell as A1.
Option Explicit
Sub ReadClosedCell()
Dim v As Variant
v = ExecuteExcel4Macro( _
"'C:\Path\To\[Nov.xlsx]Sheet1'!R1C1")
MsgBox v
End Sub
This code reads the first cell on Sheet1 in Nov.xlsx and displays the result with MsgBox.
ExecuteExcel4Macro should not be placed inside GetCellTest if that function is called directly from a worksheet cell. It will encounter the same practical limitation and return #VALUE!.
Instead, use a Sub to retrieve the value and write it into a destination cell:
Option Explicit
Sub PullValue()
Sheet1.Range("B1").Value = _
ExecuteExcel4Macro( _
"'C:\Path\To\[Nov.xlsx]Sheet1'!R1C1")
End Sub
Here, Sheet1.Range("B1") identifies the destination cell in the current workbook. The macro reads R1C1 from the closed source workbook and stores that result in B1.
How to apply it
Confirm the full file path, workbook name, worksheet name, and source cell. For the example, the workbook is
Nov.xlsx, the sheet isSheet1, and the source isA1.Decide whether the result should update through a normal Excel formula or through a macro. Use a direct external reference when a linked formula is acceptable. Use a
Subwhen the workbook must stay closed and the value should be copied into a controlled destination cell.For a formula, enter the external reference directly:
='C:\Path\To\[Nov.xlsx]Sheet1'!A1Replace the path and names with the actual location. Keep the single quotes around the full external reference.
For VBA, open the Visual Basic Editor, insert a standard module, and add
Option Explicit. This setting forces variables to be declared, which helps catch typing mistakes such as usingCellPathValuewithout declaring it.Create a
Subprocedure rather than a worksheet UDF. UseExecuteExcel4Macrowith an R1C1 address:Sub PullValue() Sheet1.Range("B1").Value = _ ExecuteExcel4Macro( _ "'C:\Path\To\[Nov.xlsx]Sheet1'!R1C1") End SubRun the macro while
Nov.xlsxis closed. CheckB1against the source cell inSheet1.If the process should run when the reporting workbook opens, call the procedure from
Workbook_Open. If operators need control over timing, assign the macro to a button instead.Test missing files and missing values before using the method in a monthly close process. A production workbook should decide whether a missing source means blank, zero, or an exception that requires attention.
The most robust design is usually to keep the external read in a Sub and write the result into a normal worksheet cell. A direct external formula is simpler, but it can create prompts or file-location issues when the path is unavailable. The macro approach gives more control over when the read occurs and where the result is stored.
Implementation angle
For a small business, this pattern can become a controlled monthly import. A macro can read selected cells from files such as Nov.xlsx, write them into a reporting table, and record which source file was processed. An automation partner could replace the fragile cell-by-cell links with a Zoho Creator workflow or a Make or n8n process that checks whether the file exists, imports the required values, and flags missing data. Claude can also help generate and review the VBA, including the R1C1 addresses and error-handling rules.
Book an AI implementation engagement with Creator Scripts at creatorscripts.com to turn this closed-workbook process into a dependable reporting workflow.
Frequently asked questions
Why does my Excel VBA function return #VALUE! when reading a cell from a closed workbook?
A VBA string stores text, not a cell reference, so it has no .Value property. Also, a worksheet function is not a reliable way to read from a closed workbook. Use a direct external formula or a VBA Sub instead.
Can I use INDIRECT to read a cell from a closed Excel workbook?
No. INDIRECT needs the referenced workbook to be open. Use a direct external reference, such as ='C:\Path\To\[Nov.xlsx]Sheet1'!A1, if you want a formula link.
How do I use VBA to get a value from a closed workbook?
Run ExecuteExcel4Macro from a Sub, using an R1C1 address such as R1C1 for cell A1. The Sub can write the result into a cell in the current workbook. A worksheet UDF is not suitable for this method.