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 you need to copy-paste each URL one by one. So the better way is to create a UDF in VBA. And, today I’d like to share with you a simple code for this UDF.
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:
- Open the visual basic editor from the developer tab or use the keyboard shortcut ALT + F11.
- Insert a new module, paste the above code into it and close it.
- Now in your worksheet, enter function =GiveMeURL(A1) and hit enter.
It will return the URL from the cell where you have a hyperlink and make sure to download this file from here.