vba 超链接到实际工作簿中的工作表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4820191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hyperlink to Worksheet in actual Workbook
提问by borlee
How can i add a Hyperlink to a specific cell and address it to a Worksheet in the Excel file?
如何将超链接添加到特定单元格并将其寻址到 Excel 文件中的工作表?
This is what I already got:
这是我已经得到的:
Cells(zeile, 1).Select
Worksheets(1).Hyperlinks.Add Anchor:=Selection, Address:=Workbooks(1).Worksheets(fortnr), SubAddress:=Cells(1, 1).Address
Thanks.
谢谢。
回答by Dick Kusleika
ActiveSheet.Hyperlinks.Add ActiveCell, "", Sheets(fortnr).Name & "!A1"
The Address should be blank and the SubAddress should be in the form Sheet1!A1. This puts a link in the activecell assuming you have a variable named fortnr that contains a valid sheet name in the same workbook.
地址应为空,而子地址应采用 Sheet1!A1 形式。这会在 activecell 中放置一个链接,假设您有一个名为 fortnr 的变量,该变量包含同一工作簿中的有效工作表名称。
If you want to point to a cell in a different workbook, then everything is the same except the Address needs to be that file.
如果您想指向不同工作簿中的单元格,那么除了地址必须是该文件之外,一切都相同。
ActiveSheet.Hyperlinks.Add ActiveCell, Workbooks(1).FullName, Sheets(fortnr).Name & "!A1"
Assuming Workbooks(1) is a different file and has been previously saved and has a sheet with the right name, etc, etc.
假设 Workbooks(1) 是一个不同的文件并且之前已经保存并且有一个名称正确的工作表等等。
回答by Kent Lau Chee Yong
Idea 1: Add a hyperlink to current active cell
思路一:给当前活动单元格添加超链接
Assume the sheet name to link to is "VBA1"
假设要链接到的工作表名称是“VBA1”
ActiveSheet.Hyperlinks.Add Activecell, "", "VBA1!A1"
ActiveSheet.Hyperlinks.Add Activecell, "", "VBA1!A1"
Idea 2: Add a hyperlink to a shape that is named as "CallButton"
想法 2:向名为“CallButton”的形状添加超链接
ActiveSheet.Hyperlinks.Add ActiveSheet.Shapes("CallButton"), "", "VBA1!A1"
ActiveSheet.Hyperlinks.Add ActiveSheet.Shapes("CallButton"), "", "VBA1!A1"


