Skip to main content

Excel: How to fix broken links

Author: Sun Last Modified: 2022-07-13

In a workbook, sometimes, you may create links to other workbooks for referring to some relevant information. But when the source workbook is renamed or moved to another location, these extra links will be broken. Here this tutorial introduces two different methods for fixing the broken links in Excel.

Fix broken links by applying Edit Links

Fix broken links by using VBA code

Fix broken links by applying Edit Links

In Excel, you can go to the Edit Links dialog to fix them one by one.

1. Enable the workbook which contains the broken links, and click Data > Edit Links (in Queries & Connections group).
doc fill text based on color 1

2. In the Edit Links dialog, click Check Status to find which links are broken.
doc fill text based on color 1 doc fill text based on color 1

3. Then click on the broken links, then click Change Source button, in the Change Source window, choose the correct source workbook, and click OK.
doc fill text based on color 1

now you can see the status changed from Error to OK, then repeat step 3 to fix other broken links.
doc fill text based on color 1

Fix broken links by using VBA code

Here introduces a VBA code that can help you.

1. Enable the workbook that you want to fix the broken links, and press Alt + F11 keys.

2. Then in the popping Microsoft Visual Basic for Applications window, click Insert > Module to create a new blank module.
doc fill text based on color 1

3. Copy and paste the below code to the new module.

VBA: Fix broken links

Sub ResetInvalidLinks()
Dim xWB As Workbook
Dim xLks As Variant
Dim xFNum, xStatus As Integer
Dim xStrLk, xLinAddress As String
Dim xF
Dim xLk
Set xWB = Application.ActiveWorkbook
xLks = xWB.LinkSources(xlExcelLinks)
If IsEmpty(xLks) Then
    MsgBox "Select updated source"
    Exit Sub
End If
On Error Resume Next
For xFNum = LBound(xLks) To UBound(xLks)
    xStrLk = xLks(xFNum)
    xStrLk = Right(xStrLk, Len(xStrLk) - InStrRev(xStrLk, "\"))
    xStatus = ActiveWorkbook.LinkInfo(xStrLk, xlLinkInfoStatus)
    If xStatus <> 0 And xStatus <> 3 Then
        MsgBox xStrLk & " the link is broken, please select new source"
        xF = Application.GetOpenFilename()
        If xF <> "" Then
            For Each xLk In ActiveSheet.UsedRange.Hyperlinks
                xLinAddress = Right(xLk.Address, Len(xLk.Address) - InStrRev(xLk.Address, "\"))
                    If InStr(xStrLk, GetAddress) <> 0 Then
                        ActiveSheet.Hyperlinks.Add Anchor:=xLk.Range, Address:=xF
                    End If
            ActiveWorkbook.ChangeLink xLks(xFNum), xF, xlLinkTypeExcelLinks
        End If
        End If
End Sub

4. Press F5 key or Run button doc run to activate the code. Now it searches if there are any broken links. If so, it pops out a dialog to tell you which link is broken, please select a new source. Click OK to continue.
doc fill text based on color 1

5. In the Open window, choose the updated source, Click OK.
doc fill text based on color 1

If there is still a broken link in the workbook, the above dialogs pop again until all broken links are fixed.

Note: if there is no broken link in the workbook, the VBA will stop after running.

Tip: if you want to view all extra links and break the broken links, Kutools for Excel’s Find and Break Broken Links feature will be a good helper.
doc fill text based on color 1

For details about this feature, please click here.

For 30-day free trial, please download from here.

Other Operations (Articles)

How To Fix/Lock Background Color In A Sheet
Sometimes, when you share a sheet with others to edit, you may want to lock the background color in a range of cells and prevent them to be changed.

How To Reduce Excel File Size?
Sometimes, it will take minutes to open or save if the Excel file is too large. For solving this problem, here in this tutorial, it tells you how to reduce the Excel file size by removing the contents or formats which are unnecessary or never used.

Excel: How To Create Or Insert A Bookmark
Have you ever imagined creating or inserting a bookmark for quickly jumping to a specific data range while there is a lot of data in a worksheet or a workbook?

How to apply shading to odd or even (alternative) rows/columns in Excel?
While designing a worksheet, many people tend to apply shading to odd or even (alternative) rows or columns in order to make the worksheet more visual. This article will show you two methods to apply shading to odd or even rows/columns in Excel.


  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom


Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations