问题
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