Preserve Excel Linked Spill Ranges After Workbook Links Break with VBA
Question details
The user needs a VBA workaround to preserve a linked spilled array range when the source workbook is distributed or disconnected, so formulas using the spill-reference operator (#) can still resolve the range instead of returning #REF!.

- Product
- Microsoft Excel and WPS Office Spreadsheets
- Device & OS
- not provided
- Scenario
- A workbook contains linked spilled array ranges from an external source workbook. After the source workbook is distributed or the link is disconnected, the spill becomes a static range.
- Observed behavior
- Formulas that use the spill operator, such as =VLOOKUP(value,AA100#,2,FALSE), return #REF! because the original spill dimensions are no longer available.
Make sure the top-left cell of the original spill range has a note storing the dimensions as rows x columns (for example, 10x4), and save the workbook as a macro-enabled file so the VBA function can run.
Rebuild linked spill ranges with the LS VBA function
Use this method when a linked spilled array becomes a static range after the source workbook is disconnected and spill-reference formulas return #REF!.
The LS function checks whether the top-left cell still has a live spill. If it does, the function returns TLC.SpillingToRange. If the link has broken, it reads the stored dimensions from a note on the top-left cell and rebuilds the original rectangular range.
In WPS Office Spreadsheets, click the Developer tab and choose Visual Basic, or press Alt+F11 to open the Microsoft Visual Basic for Applications editor.
In the Project pane, right-click the workbook or VBAProject, choose Insert > Module, and open the new module window.
Add a Public Function named LS that takes TLC As Range. If TLC.HasSpill is true, return TLC.SpillingToRange. Otherwise read the note text from TLC.Comment.Text, split it on the x separator to get rows and columns, calculate the bottom-right cell with TLC.Worksheet.Cells(TLC.Row + rows - 1, TLC.Column + columns - 1), and return Range(TLC, BRC).
Run an importSpill macro or manually add a comment/note to the top-left spill cell in the rows x columns format so the LS function can rebuild the range after the link breaks.
Change formulas from direct spill references such as AA100# to LS(AA100). For example, use =VLOOKUP(A2,LS(AA100),2,FALSE) or =INDEX(LS(AA100),1,4).
Save the workbook in a macro-enabled format, allow macros when prompted, and test with changed spill sizes, broken links, error values, comments, and large data ranges before deployment.

Manually rebuild the spill range from the stored note
Use this fallback when you cannot enable macros or need to verify the rebuilt range by hand.
Preserve Excel-Linked Spill Ranges in WPS Office with a VBA LS Function
WPS Office can run the same VBA LS user-defined function approach, letting you rebuild linked spill ranges after workbook links break and keep spill-reference formulas such as VLOOKUP and INDEX working.
- 1. Open WPS Spreadsheets: Launch WPS Office and open the macro-enabled workbook that contains the linked spill formulas.
- 2. Open the VBA editor: Go to Developer > Visual Basic or press Alt+F11 to open the VBA editor.
- 3. Add the LS function: Insert a module, paste the LS function, and add an importSpill macro that stores the current spill dimensions in the top-left cell note.
- 4. Update formulas and save: Replace # spill-reference formulas with LS(range) and save the workbook as a macro-enabled file.
- 5. Enable macros and validate: Allow macros when reopening, then test broken links, changed spill sizes, comments, and recalculation performance.

Frequently Asked Questions
Why do my spill-reference formulas return #REF! after the source workbook link breaks?
The spilled array behind the # reference becomes a static range when the link is broken or the workbook is opened without the source, so Excel can no longer resolve the spill operator to a range.
Can I use the LS VBA function in WPS Office?
Yes. WPS Office supports VBA user-defined functions in macro-enabled workbooks. Open Developer > Visual Basic, insert the LS function in a module, save as a macro-enabled format, and allow macros when prompted.
What format should the stored spill dimensions use?
Store them in a note on the top-left cell as rows x columns, such as 10x4. The LS function splits the note text on the x separator and calculates the bottom-right cell.
Can LS be used inside VLOOKUP and INDEX?
Yes. Typical formulas include =VLOOKUP(A2,LS(AA100),2,FALSE) and =INDEX(LS(AA100),1,4), where AA100 is the top-left cell of the original spill.
What should I test before deploying this VBA workaround?
Test different spill sizes, broken links, error values, cell comments or notes, and recalculation performance to make sure the function behaves correctly in your workbook configuration.




