Thread: sorting links
View Single Post
  #2   Report Post  
Bill Manville
 
Posts: n/a
Default


In previous tests I have not reproduced a problem of hyperlinks not
sorting with the cells containing them.

I would be interested in seeing the file
( Bill_Manville @ compuserve.com , without the spaces)

Which version of Excel are you using?

A fix would be to use the HYPERLINK worksheet function to create your
links. The following macro should change all hyperlinks in a selected
range into HYPERLINK function calls

Sub MakeHyperlinkFunctions()
Dim C As Range
Dim H As Hyperlink
Dim stDest As String
For Each C In Selection.Cells
If C.Hyperlinks.Count 0 Then
Set H = C.Hyperlinks(1)
stDest = H.Address
If H.SubAddress < "" Then stDest = stDest & "#" & H.SubAddress
If C.HasFormula Then
If Left(C.Formula, 11) < "=HYPERLINK(" Then
C.Formula = "=HYPERLINK(""" & stDest & """," & Mid(C.Formula,
2) & ")"
End If
Else
C.Formula = "=HYPERLINK(""" & stDest & """,""" & C.Text & """)"
End If
End If
Next
End Sub



Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup