How to Preserve External Workbook Links in Excel Defined Names
Question details
The user needs a method to prevent external links stored in defined names from disappearing from the LinkSources collection after executing a macro.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Processing defined names containing external workbook links via an Excel macro.
- Observed behavior
- External links stored only in defined names disappear from Excel's LinkSources collection after macro processing, even though the references remain visible in the Name Manager.
Before making changes to external links and defined names, ensure you save a backup copy of your workbook. This protects your original data while testing the macro and reference updates.
Add Explicit Worksheet References
Adding a direct cell reference to the external workbook forces Excel to recognize and retain the link in its LinkSources collection.
Excel sometimes struggles to track external links if they are exclusively stored within the Name Manager. When a macro processes these names, the connection in the LinkSources collection may break, causing missing data or VBA errors.
To solve this behavior, you can manually establish an explicit connection to the external file directly on a worksheet. This forces Excel's LinkSources property to recognize and preserve the connection permanently.
Open your main workbook and navigate to a blank or dedicated worksheet. You can choose to hide this sheet later so it doesn't interfere with your main data.
Select an empty cell, type `=`, and navigate to the open external workbook. Click on any cell (e.g., `Sheet1!A1`) and press Enter to create an explicit reference such as `='[ExternalWorkbook.xlsx]Sheet1'!A1`.
Repeat this process to create one explicit reference for every external workbook that your defined names rely on.
Save the workbook and run your macro again. The `ThisWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)` property will now correctly preserve and detect the connections.

Check for Phantom External Links
Identify hidden or phantom external links that might be interfering with your workbook's LinkSources collection.
Try WPS Office for Reliable Spreadsheet Management
If you frequently encounter frustrating bugs with macros, phantom links, or Name Manager issues in Microsoft Excel, consider switching to WPS Office. It is a powerful, lightweight, and completely free alternative that seamlessly handles complex spreadsheet tasks.

Frequently Asked Questions
Why do external links disappear from the LinkSources collection?
In some versions of Excel, if external links are only referenced inside the Name Manager (defined names) and not physically on a worksheet, Excel's VBA LinkSources method may fail to detect them after a macro updates or calculates the workbook.
How can I view all external links in my workbook?
Go to the Data tab on the Excel ribbon and click 'Edit Links' in the Queries & Connections group. This dialog box displays all active external workbook references and allows you to update or break them.
What are phantom links in Excel?
Phantom links are external references that no longer exist in formulas or active defined names but are still cached by Excel's hidden objects, charts, or corrupted Name Manager entries. They often trigger unwanted 'Update Links' prompts when opening the file.
Can I hide the explicit worksheet references used in the workaround?
Yes. You can place all your explicit external references on a single worksheet, right-click the worksheet tab at the bottom, and select 'Hide'. Excel will still read the references and preserve the external links without cluttering your main workspace.




