且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 Excel 单元格中的超链接文本中提取 URL

更新时间:2023-02-13 17:37:39

您可以使用 vba 宏:

You could use a vba macro:

点击 Alt+F11 打开 VBA 编辑器并粘贴以下内容:

Hit Alt+F11 to open the VBA editor and paste in the following:

Function URL(rg As Range) As String
  Dim Hyper As Hyperlink
  Set Hyper = rg.Hyperlinks.Item(1)
  URL = Hyper.Address
End Function

然后你可以在你的工作表中使用它,就像这样:

And then you can use it in your Worksheet, like this:

=URL(B4)