Home |
Search |
Today's Posts |
#5
![]() |
|||
|
|||
![]() Bill! Thank you very much, your code solved this difficult problem. Best regards, Branko "Bill Manville" wrote: Further for the record. Branko sent me a reproduceable example. I discovered that some cells had 2 hyperlinks attached and that some of the hyperlinks were associated with multiple cells. I wrote a macro to resolve those issues, replacing multi-cell hyperlinks with single cell ones and, where 2 hyperlinks had been in a cell putting the second hyperlink in a spare cell to the right so that Branko could decide which one to keep. The macro went like this: Sub FixHyperlinks() Dim C As Range Dim H As Hyperlink Dim R As Range Dim C2 As Range Dim I As Integer Dim stDest As String For Each C In Selection.Cells For I = C.Hyperlinks.Count To 1 Step -1 Set H = C.Hyperlinks(I) Set R = H.Range If R.Address < C.Address Then ' we have a multiple cell hyperlink - note the destination stDest = H.Address If H.SubAddress < "" Then stDest = stDest & "#" & H.SubAddress H.Delete Debug.Print "Deleted hyperlink from " & R.Address For Each C2 In R.Cells If C2.Hyperlinks.Count = 0 Then ' we removed the hyperlink from this cell C2.Hyperlinks.Add C2, stDest, , , C2.Text Debug.Print "Added hyperlink to " & C2.Address Else ' put the removed hyperlink 2 cells to right C2.Offset(, 2).Hyperlinks.Add C2.Offset(, 2), stDest, , , C2.Text End If C2.Style = "Hyperlink" Next End If Next Next End Sub Bill Manville MVP - Microsoft Excel, Oxford, England No email replies please - respond to newsgroup |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Phantom links | Excel Discussion (Misc queries) | |||
Links to other files | Excel Discussion (Misc queries) | |||
Manually update links | Excel Worksheet Functions | |||
HELP!!! Missing Links!!! | New Users to Excel | |||
Links in formulas change when another user runs a workbook | Excel Discussion (Misc queries) |