Forum Discussion
Louie Warren
Dec 05, 2017Copper Contributor
Excel - mass changing hyperlinks
Using Microsoft Professional Plus 2013
I have a spreadsheet created from an Oracle query in TOAD. The results are considered Detail. I then insert a Summary sheet for each Detail sheet. I do...
- Dec 22, 2017
Recording a macro to change the hyperlink in one cell will give you:
Range("E5").Select Selection.Hyperlinks(1).SubAddress = "Detail!H3"
To change every hyperlink in column E you will need to:
- Loop through each cell in column E
- Check if the cell has a hyperlink because trying to change a non-existent hyperlink will throw an error
- Change the hyperlink to something that can be expressed in a formula based on where the cell is within column E (i.e. its ROW)
Based on your Dummy workbook it seems that hyperlink is to a cell two rows above in column H of the Detail sheet. The following code limits the loop to the UsedRange because looping through all 1048576 is inefficient.
Sub EditHyperlinks2() Dim cel As Range With ThisWorkbook.Sheets("Summary") For Each cel In Intersect(.[E:E], .UsedRange) If cel.Hyperlinks.Count > 0 Then cel.Hyperlinks(1).SubAddress = "Detail!H" & cel.Row - 2 End If Next End With End Sub
Louie Warren
Dec 07, 2017Copper Contributor
Here is a mock up of what I have. Cells E4 and E5 the hyperlink has been manually corrected. The rest of the rows are default. Thanx