excel: get urls from hyperlinks


Extract URL link from EXCEL hyperlink


The Case

We have a formatted hyperlink in EXCEL on cell(A1) that looks like:
Extract URL Tips
But we want to extract to cell(B1) the URL behind it:

The Code


Function URL_text(HyperlinkCell As Range)
   URL_text = Replace(HyperlinkCell.Hyperlinks(1).Address, "mailto:", "")
End Function

The Implementation

Go to the VBA page (Alt+F11); then go to Insert > Module and paste the code and save it.

The Use

On cell(B1) type the following:
=URL_text(A1)
NOTE: cell(A1) is the cell with the hyperlink.

No comments:

Post a Comment