We help IT Professionals succeed at work.

Edit multiple hyperlinks in Excel 2013

I need to change many hyperlinks on an excel spreadsheet to point to a new location. I want to keep the filename the same, just change the network path. I've tried a few different scripts with no success.

This doesn't work:

Sub FixHyperlinks()
    Dim wks As Worksheet
    Dim hl As Hyperlink
    Dim sOld As String
    Dim sNew As String

    Set wks = ActiveSheet
    sOld = "\\servera\2014\DC1\CDP\Archive_Target\Denise's Files\Residential Work Orders\"
    sNew = "\\NEWSERVER\SharedData\Location\Residential Maintenance\Denise's Files\Residential Work Orders\"
    For Each hl In wks.Hyperlinks
        hl.Address = Replace(hl.Address, sOld, sNew)
    Next hl
End Sub

Please advise.
Watch Question

This seems to work for me...maybe it's not finding sOld?
Try adding this immediately after the For:

Debug.Print "Pos=" & InStr(hl.Address, sOld) & " for " & hl.Address

In your output window all hyperlinks will be listed and it the pos listed is greater than 0, the replace should be applied.

If you expect this to change again at some point, it may make more sense to add symbolic links so you don't have to change all these.  i.e. define something on Windows like "Drive N=\\NEWSERVER\SharedData\Location\etc."
then update all your links to use N: and if needed change the definition of N: on Windows.