Suppose you have a list of data with the same hyperlinks. With VBA code, you can quickly replace the old file path or address with a new one. Here’s how to do so:
1. Press the ALT + F11 keys, to open the Microsoft Visual Basic for Applications Window.
2. Click Insert > Module, and paste the following macro in the Module window.
3. Paste the following script.
Sub FixHyperlinks() Dim wks As Worksheet Dim hl As Hyperlink Dim sOld As String Dim sNew As String Set wks = ActiveSheet sOld = "URL" sNew = "NEW URL" For Each hl In wks.Hyperlinks hl.Address = Replace(hl.Address, sOld, sNew) Next hl End Sub
Note: be sure to add your own URLs for sOld and SNew.
4. Press F5 to run the macro.