Extract URL From Excel Hyperlink Formula

后端 未结 6 1758
温柔的废话
温柔的废话 2020-12-06 08:00

I have an Excel file with hundreds of cells that use the Hyperlink formula =HYPERLINK( , ). I need to extract the plain te

6条回答
  •  粉色の甜心
    2020-12-06 08:50

    Hm - playing around with it, I couldn't get .Address to work either.

    You say you want to extract the URL only, I was able to do that with this macro:

    Function hyperlinkText(pRange As Range) As String
    Dim st1 As String, st2 As String
    Dim tempSub1 As String, tempSub2 As String
    
    If Left(pRange.Formula, 10) <> "=HYPERLINK" Then
        hyperlinkText = "not found"
        Exit Function
    Else
        tempSub1 = WorksheetFunction.Substitute(pRange.Formula, """", "[", 1)
        tempSub2 = WorksheetFunction.Substitute(tempSub1, """", "]", 1)
        hyperlinkText = Mid(tempSub2, WorksheetFunction.Find("[", tempSub2) + 1, WorksheetFunction.Find("]", tempSub2) - WorksheetFunction.Find("[", tempSub2) - 1)
    End If
    
    End Function
    

    Note though, it doesn't get the "Friendly Name" of the Hyperlink() formula, just the URL.

提交回复
热议问题