Created
March 26, 2014 15:51
-
-
Save KorbenC/9786521 to your computer and use it in GitHub Desktop.
Find and replace hyperlinks in excel wkbk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub FindReplaceHLinks(sFind As String, sReplace As String, _ | |
Optional lStart As Long = 1, Optional lCount As Long = -1) | |
'Variables | |
Dim rCell As Range | |
Dim hl As Hyperlink | |
Dim Current As Worksheet | |
'Loops through each worksheet | |
For Each Current In Worksheets | |
For Each rCell In Current.UsedRange.Cells | |
If rCell.Hyperlinks.Count > 0 Then 'If hyperlink exist | |
For Each hl In rCell.Hyperlinks 'loop through each hyperlink | |
'Do change | |
hl.Address = Replace(hl.Address, sFind, sReplace, lStart, lCount, vbTextCompare) | |
Next hl | |
End If | |
Next rCell | |
'MsgBox Current.Name | |
Next | |
End Sub | |
Sub Doit() | |
'Enter Old Hyperlink address on Left and new Hyperlink address on right | |
FindReplaceHLinks "\\127.0.0.1\", "\\192.168.1.1\" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment