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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top