Skip to content

Instantly share code, notes, and snippets.

@kaspim
Created December 2, 2020 08:14
Show Gist options
  • Save kaspim/08583c38641981e6934891e5859a1284 to your computer and use it in GitHub Desktop.
Save kaspim/08583c38641981e6934891e5859a1284 to your computer and use it in GitHub Desktop.
VBA script for extracting URLs from cells in Excel
Public Function GetURL(c As Range) As String
On Error Resume Next
If Len(c.Hyperlinks(1).SubAddress) = 0 Then
GetURL = c.Hyperlinks(1).Address
Else
GetURL = c.Hyperlinks(1).Address & "#" & c.Hyperlinks(1).SubAddress
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment