Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Hyperlink mass update

Tags:

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?

like image 726
IMHO Avatar asked May 10 '10 17:05

IMHO


People also ask

What is the fastest way to edit hyperlinks in Excel?

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.

How do I change the text to display in hyperlink for multiple cells?

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.


1 Answers

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 
like image 50
Dick Kusleika Avatar answered Sep 28 '22 09:09

Dick Kusleika