hyperlinks

  • Thread starter Thread starter dstiefe
  • Start date Start date
D

dstiefe

I have a word in a cell that is a hyperlink

how do i use VBA to assign the URL of the hyperlink to a variable?

Thank you
 
First, a single word in a cell that contains multiple words can't be assigned to
a hyperlink. The entire cell is assigned the hyperlink.

Dim myCell As Range
Dim myURL as string

Set myCell = ActiveSheet.Range("A1")

If myCell.Hyperlinks.Count > 0 Then
myurl = myCell.Hyperlinks(1).Address
Else
myURL ""
End If
 
Back
Top