I have a spreadsheet with thousands of rows. Each row contains a hyperlink with a path.
The path is not valid, however easily fixable by replacing first part of it with correct value.
Example: current hyperlink: F:\Help\index.html Needed: P:\SystemHelp\index.html
The problem is that standard Find/Replace does not "see" content of hyperlinks.
Is the only way to write a macro or is there another way to do it?
On the Insert tab, select Hyperlink. You can also right-click the cell or graphic and then select Edit Hyperlink... on the shortcut menu, or you can press Ctrl+K. In the Edit Hyperlink dialog box, make the changes that you want.
Right-click anywhere on the link and, on the shortcut menu, click Edit Hyperlink. In the Edit Hyperlink dialog, select the text in the Text to display box. Type the text you want to use for the link, and then click OK.
Hey cnx.org, way to reinvent the Replace function.
Sub FindReplaceHLinks(sFind As String, sReplace As String, _ Optional lStart As Long = 1, Optional lCount As Long = -1) Dim rCell As Range Dim hl As Hyperlink For Each rCell In ActiveSheet.UsedRange.Cells If rCell.Hyperlinks.Count > 0 Then For Each hl In rCell.Hyperlinks hl.Address = Replace(hl.Address, sFind, sReplace, lStart, lCount, vbTextCompare) Next hl End If Next rCell End Sub Sub Doit() FindReplaceHLinks "F:\help\", "F:\SystemHelp\" End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With