View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mark Ivey[_2_] Mark Ivey[_2_] is offline
external usenet poster
 
Posts: 171
Default Hyperlink - Data Validation

Forgot to give credit for the function...

I got this function from:
http://www.dailydoseofexcel.com/arch...ry/vba-basics/
by Juan Pablo Gonzalez.

Mark Ivey



"Mark Ivey" wrote in message
...
I am not totally sure of your layout, but here is something you might can
work with to get to where you want it to go.
It will probably need some modification to do what you want to do.

If I can help out more, just let me know...

Mark Ivey



Sub set_commentbox_to_display_hyperlink_info()
Dim myHyperlink As String

On Error GoTo hyper_Error

Range("A1").AddComment
Range("A1").Comment.Visible = False
myHyperlink = RETURNHYPERLINK(Range("B1"))
Range("A1").Comment.Text Text:=myHyperlink

On Error GoTo 0
Exit Sub

hyper_Error:
MsgBox "There is already a commentbox used here.", vbOKOnly

End Sub

Function RETURNHYPERLINK(Rng As Range) As String
If Rng.Hyperlinks.Count 0 Then
RETURNHYPERLINK = Rng.Hyperlinks(1).Address

If Len(RETURNHYPERLINK) = 0 Then
RETURNHYPERLINK = Rng.Hyperlinks(1).SubAddress
End If
End If
End Function