excel - 从超链接问题中提取 URL

excel - 从超链接问题中提取 URL

在 A 列中有一个包含值的电子表格

显示文本 = “站点信息”

超链接 URL https://mylocation.org/secure/Setup!default.jspa?Key=MDF#/rule/335 https://mylocation.org/secure/Setup!default.jspa?Key=MDF#/rule/337

有没有办法获取超链接的值?

寻找

公式(B1)=“https://mylocation.org/secure/Setup!default.jspa?Key=MDF#/rule/335”公式(B2)=“https://mylocation.org/secure/Setup!default.jspa?Key=MDF#/rule/337”

找到这个 VBA

Function GetURL(rng As Range) As String
     On Error Resume Next
     GetURL = rng.Hyperlinks(1).Address 
End Function

=GETURL(A1)

问题是它可以工作,但它会返回https://mylocation.org/secure/Setup!default.jspa?Key=MDF#代替https://mylocation.org/secure/Setup!default.jspa?Key=MDF#/rule/335

在 # 之前停止。

问题:如何获取 # 后的完整 URL?

答案1

您需要添加子地址:

Function GetURL(rng As Range) As String
     On Error Resume Next
     GetURL = rng.Hyperlinks(1).Address & rng.Hyperlinks(1).SubAddress 
End Function

相关内容