ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hyperlink - Data Validation (https://www.excelbanter.com/excel-programming/406985-hyperlink-data-validation.html)

ALEX

Hyperlink - Data Validation
 
Hi,

I have cell A1 display values based on data validation from a list that is
column B.

The values in column B are hyperlinked to different web address.

Is there a way to have cell A1 display tthe hyperlink when a value is
selected?

Maybe with a macro??

Thanks
Alex

Mark Ivey[_2_]

Hyperlink - Data Validation
 
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


Mark Ivey[_2_]

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




All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com