How to Extract Hyperlink Address (URL) in Excel Using VBA UDF

Let's say you got an Excel workbook from your colleague where you have a list of hyperlinks in a column.

Now from this list, you want to extract all the hyperlink URL addresses.

The manual method is a real pain...

VBA code to Extract Hyperlink URLs

Function GiveMeURL(rng As Range) As String
On Error Resume Next
GiveMeURL = rng.Hyperlinks(1).Address
End Function

How to use this Code

To use this UDF, you need to follow these steps:

  1. Open visual basic editor from developer tab or use keyboard shortcut ALT + F11.
  2. Insert a new module, paste above code into it and close it.
  3. Now in your worksheet, enter function [=GiveMeURL(A1)] and hit enter.

About the Author

puneet one point one

Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can find him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.