To list all external links in an Excel workbook, you can use a VBA macro that iterates through every worksheet and cell to identify formulas containing brackets (which denote external references) and outputs them to a new sheet. This process is essential for auditing large workbooks where the built-in "Edit Links" tool tells you that links exist but does not tell you exactly which cells contain them.

What You'll Need

  • Microsoft Excel installed on a Windows or Mac computer.
  • A workbook containing the external links you wish to identify.
  • Basic access to the Developer tab (or the ability to open the VBA editor via keyboard shortcuts).

Step-by-Step

  1. Open your workbook: Launch the Excel file that contains the external links you need to find.
  2. Open the VBA Editor: Press Alt + F11 on your keyboard. This opens the Visual Basic for Applications (VBA) editor window.
  3. Insert a New Module: In the top menu, go to Insert > Module. A blank white window will appear; this is where you will paste the code.
  4. Paste the VBA Code: Copy and paste the following code into the module window:
    Sub ListExternalLinks()
        Dim ws As Worksheet
        Dim linkSheet As Worksheet
        Dim cell As Range
        Dim firstAddress As String
        Dim rowNum As Long
        
        ' Create a new sheet to list the links
        Set linkSheet = Worksheets.Add
        linkSheet.Name = "External Links Report " & Format(Now, "hhmmss")
        linkSheet.Range("A1:C1").Value = Array("Sheet Name", "Cell Address", "Formula")
        rowNum = 2
        
        ' Loop through all sheets in the workbook
        For Each ws In ThisWorkbook.Worksheets
            ' Skip the report sheet itself
            If ws.Name <> linkSheet.Name Then
                ' Find cells with formulas containing "[" which indicates an external link
                On Error Resume Next
                Set cell = ws.Cells.Find(What:="[", LookIn:=xlFormulas, LookAt:=xlPart)
                On Error GoTo 0
                
                If Not cell Is Nothing Then
                    firstAddress = cell.Address
                    Do
                        linkSheet.Cells(rowNum, 1).Value = ws.Name
                        linkSheet.Cells(rowNum, 2).Value = cell.Address
                        linkSheet.Cells(rowNum, 3).Value = "'" & cell.Formula
                        rowNum = rowNum + 1
                        Set cell = ws.Cells.FindNext(cell)
                    Loop While Not cell Is Nothing And cell.Address <> firstAddress
                End If
            End If
        Next ws
        
        linkSheet.Columns("A:C").AutoFit
        MsgBox "External links list complete!", vbInformation
    End Sub
    
  5. Run the Macro: While still in the VBA editor, press F5 or click the green "Run" arrow in the toolbar.
  6. Review the Results: Switch back to your Excel workbook. You will see a newly created worksheet containing a list of every sheet, cell address, and the specific formula that links to an external file.

Common Mistakes

  • Running the macro on a protected sheet: If any of your worksheets are password-protected or locked, the macro may encounter an error. Unprotect your sheets before running the code.
  • Confusing internal and external links: This macro specifically looks for the [ character. If you have internal links (links to other sheets in the same workbook), they will not be listed because they do not use brackets.
  • Forgetting to save as .xlsm: Standard .xlsx files cannot store VBA macros. If you want to keep this tool for future use, you must save your file as an Excel Macro-Enabled Workbook (.xlsm).

Tips

  • Use the Apostrophe: In the code provided, the formula is preceded by an apostrophe ("'" & cell.Formula). This ensures that Excel treats the formula as text in the report sheet rather than trying to execute the link itself.
  • Audit and Break: Once you have the list, you can use the Ctrl + G (Go To) shortcut in Excel, enter the cell address from your report, and quickly navigate to the link to decide if it should be broken or updated.
  • Performance: In extremely large workbooks (tens of thousands of formulas), the FindNext method is significantly faster than looping through every single cell in a range.

Troubleshooting

If the macro does not work as expected, try these steps in order:

  1. Check Macro Settings: If the code won't run, go to File > Options > Trust Center > Trust Center Settings > Macro Settings and ensure that "Disable all macros with notification" is selected. You must click "Enable Content" in the yellow bar at the top of the screen when you open the file.
  2. Verify Formula Content: Ensure your external links are actually in formulas. This macro finds cell formulas; it will not find links hidden in Named Ranges, Data Validation, or Conditional Formatting.
  3. Clear Old Report Sheets: If you run the macro multiple times, it will create multiple "External Links Report" sheets. Delete old report sheets to keep your workbook clean.
  4. Check for Errors: If the macro stops and highlights a line in yellow, check if the sheet you are scanning is currently empty or filtered in a way that prevents the Find method from working.

Frequently Asked Questions

Will this macro remove the links?

No, this macro only lists the links. It does not change, delete, or break any existing formulas in your workbook.

Can this find links in Named Ranges?

No, this specific code scans cell formulas. To find links in Named Ranges, you would need a separate loop that iterates through ThisWorkbook.Names.

Does this work on Excel for Mac?

Yes, the VBA code provided is compatible with Excel for Mac, though the keyboard shortcut to open the editor may differ (usually Opt + F11).

What happens if there are no external links?

The macro will still create a report sheet with the headers, but the list below the headers will remain empty, and you will receive the "complete" notification.

Can I use this to find links to other sheets in the same file?

No. Internal links do not use the square bracket [ ] notation. This tool is specifically designed for external workbook references.