Download CV

How to extract URLs from a hyperlinks on Excel

June 22, 2023
  1. Open up a new workbook.
  2. Get into VBA (Press Alt+F11)
  3. Insert a new module (Insert > Module)
  4. Copy and Paste the Excel user defined function below
    Function GetURL(cell As Range, _
    Optional default_value As Variant)
    'Lists the Hyperlink Address for a Given Cell
    'If cell does not contain a hyperlink, return default_value
    If (cell.Range("A1").Hyperlinks.Count <> 1) Then
    GetURL = default_value
    Else
    GetURL = cell.Range("A1").Hyperlinks(1).Address & "#" & cell.Range("A1").Hyperlinks(1).SubAddress
    End If
    End Function
  5. Get out of VBA (Press Alt+Q)
  6. Use this syntax for this custom Excel function: =GetURL(cell,[default_value])

Posted in All
Write a comment