VBA & Macro Problems

Preserve Excel Linked Spill Ranges After Workbook Links Break with VBA

Muhammad TalhaMuhammad Talha Nov 13, 2026 868 views

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

Preserve Excel Linked Spill Ranges After Workbook Links Break with VBA
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

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.

2
Insert a standard module

In the Project pane, right-click the workbook or VBAProject, choose Insert > Module, and open the new module window.

3
Paste the LS function code

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

4
Store the spill dimensions before distribution

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.

5
Replace broken spill references

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

6
Enable macros and test

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.

Rebuild linked spill ranges with the LS VBA function
Result: When HasSpill is true, the UDF returns the live spill range. After the link breaks, it reconstructs the original range from the stored note dimensions so formulas can keep working.

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. 1. Open WPS Spreadsheets: Launch WPS Office and open the macro-enabled workbook that contains the linked spill formulas.
  2. 2. Open the VBA editor: Go to Developer > Visual Basic or press Alt+F11 to open the VBA editor.
  3. 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. 4. Update formulas and save: Replace # spill-reference formulas with LS(range) and save the workbook as a macro-enabled file.
  5. 5. Enable macros and validate: Allow macros when reopening, then test broken links, changed spill sizes, comments, and recalculation performance.
Rebuilds broken linked spill ranges without manually recreating every formula.Works with Excel .xlsm and .xlsx workbook formats and VBA macros.Returns the live spill range when available and reconstructs it after the link breaks.Free, lightweight, and familiar spreadsheet interface for macro-enabled workbooks.
QA img-9

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.