How to Extract URLs with Excel

How-To Jan 28, 2024

Sometimes, you need to extract URLs from links you get in excel.

I have the perfect VBA function that can help you out with this.

In Excel for Windows or Mac, you can create a custom VBA function, as follows:

  1. Press ALT+F11 to activate the Visual Basic Editor
  2. Select Insert > Module
  1. Copy the code listed below into the module
Function GetURL(cell As Range) As String
    GetURL = cell.Hyperlinks(1).Address
End Function
  1. Switch back to Excel. You can close the window.
  2. With a hyperlink in A1, the formula "=GetURL(A1)" will return the URL of the hyperlink in the A1 cell.
  1. Save the workbook as macro-enabled workbook (*.xlsm extension).
  1. Make sure that you allow macros when you open the workbook. If the pop up window doesn't work or the macro doesn't work, check and make sure you allow macros in Excel.

Go to File -> Options -> Trust Center -> Macro Settings

Tags