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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 11:06:24  来源:igfitidea点击:

Hyperlink to Worksheet in actual Workbook

vbahyperlinkworksheetexcel

提问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"

回答by live-love

If you are trying to do this via UI:

如果您尝试通过 UI 执行此操作:

  • Go to Insert, Hyperlink

  • Select Place in This Document

  • Select the worksheets and the cells you want to add.

  • 转到插入,超链接

  • 选择在此文档中的位置

  • 选择要添加的工作表和单元格。

The links will be added in your spreasheet.

这些链接将添加到您的电子表格中。

enter image description here

在此处输入图片说明