LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Branko
 
Posts: n/a
Default


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Phantom links KG Excel Discussion (Misc queries) 3 March 20th 05 04:41 PM
Links to other files Eric Excel Discussion (Misc queries) 1 February 24th 05 10:49 PM
Manually update links Emma Excel Worksheet Functions 0 February 22nd 05 01:23 PM
HELP!!! Missing Links!!! [email protected] New Users to Excel 2 February 16th 05 03:20 PM
Links in formulas change when another user runs a workbook L Mehl Excel Discussion (Misc queries) 2 November 27th 04 09:27 PM


All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"