Excel has some strange behaviors, one of them is that the “find & replace” function doesn’t work with hyperlinked content. In order to overcome this you need to use a simple macro. Here are the steps to take:
- While on the spreadsheet you wish to edit press ALT + F11 – this will open the Visual Basic Application Window
- Click Insert > Module, and paste the following macro in the Module window
123456789101112131415Sub ReplaceHyperlinks()'Updated20170724Dim Ws As WorksheetDim xHyperlink As HyperlinkDim xOld As String, xNew As StringxTitleId = "toolsforExcel"Set Ws = Application.ActiveSheetxOld = Application.InputBox("Old text:", xTitleId, "", Type:=2)xNew = Application.InputBox("New text:", xTitleId, "", Type:=2)Application.ScreenUpdating = FalseFor Each xHyperlink In Ws.HyperlinksxHyperlink.Address = Replace(xHyperlink.Address, xOld, xNew)NextApplication.ScreenUpdating = TrueEnd Sub - Run this Macro by pressing F5 – fill the old and new text in the popup boxes and it will make the replace
working! Thank You!
Compile Error:
Expected: end of statement
If I am supposed to just use the content in the above example, what am I missing?
Hi David,
What version of excel are you using?
Are you sure you copied the entire code above with no missing characters?
Damn this was so easy! Took me more time to find your solution than to run it and fix all my spreadsheets! You may want to make a note that not only will it replace whole URL’s but will also change parts of the URL. I changed just the name of a subdirectory, and didn’t have to enter the entire URL, just the text I wanted changed.
Thanks!