Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

Get url from hyperlink column cells

I have an excel worksheet with two columns:

Site          url
--------      ------
Site1       ...
Site2       ...
.
.

Question: How can I get url text from hyperlinked Site column and store it as text in url column for each row?
ASKER CERTIFIED SOLUTION
Avatar of Wilder1626
Wilder1626
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Eghtebas

ASKER

How can I loop through all the rows in the active worksheet to do this?
If (cell.Range("D1").Hyperlinks.Count <> 1) Then
cell.Range("D1").Text = cell.Range("D1").Hyperlinks(1).Address & "#" & cell.Range("D1").Hyperlinks(1).SubAddress
End If

Open in new window

Actually, you don't need to change anything in the module.

Just by pasting the formula in the cells will automatically update the URL text.
Ex:
User generated imageGet-URL-2.xlsm
Are you able to test like this?

Module:
Function GetURL(rang As Range) As String
  If rang(1).Hyperlinks.Count Then GetURL = rang.Hyperlinks(1).Address
End Function

Open in new window


Then, the formula will again be for example: =GetURL(D1)

To your question, yes, it is only a function call.
You may want to also try my last function. shorter and still work great. :)