我希望在VBA中创建一个超链接,点击后会跳转到特定的单元格,类似于HTML锚链接。
例如:
ActiveSheet.Hyperlinks.Add Anchor:=Cells(1, 2), Address:=range("B23"), TextToDisplay:="Test Link"
然而,上述内容并不起作用,因为它说地址未找到
答案 0 :(得分:4)
您需要Hyperlinks.Add method的SubAddress
参数,而不是Address
。
with ActiveSheet
.Hyperlinks.Add Anchor:=.Cells(1, 2), _
Address:="", _
SubAddress:= .Name & "!$B$23", _
TextToDisplay:="Test Link"
end with
答案 1 :(得分:2)
尝试这种方式:
ActiveSheet.Hyperlinks.Add Anchor:=ActiveSheet.Range("E5"), Address:="", SubAddress:="Sheet1!A1", TextToDisplay:="Sheet1!A1"