Hyperlink to Worksheet in actual Workbook

本小妞迷上赌 提交于 2020-01-14 16:48:07

问题


How can i add a Hyperlink to a specific cell and address it to a Worksheet in the Excel file?

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.


回答1:


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.

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.




回答2:


Idea 1: Add a hyperlink to current active cell

Assume the sheet name to link to is "VBA1"

ActiveSheet.Hyperlinks.Add Activecell, "", "VBA1!A1"

Idea 2: Add a hyperlink to a shape that is named as "CallButton"

ActiveSheet.Hyperlinks.Add ActiveSheet.Shapes("CallButton"), "", "VBA1!A1"




回答3:


If you are trying to do this via 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.



来源:https://stackoverflow.com/questions/4820191/hyperlink-to-worksheet-in-actual-workbook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!