Hyperlink to Worksheet in actual Workbook
22,513
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.
Author by
borlee
Updated on April 06, 2020Comments
-
borlee about 4 years
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.
-
borlee over 13 yearsok that works, but if i open up a diffrent excel file first it will try to link the hyperlink to that file. is it possible to always link it to the active workbook? the name of the excel file changes itself alot, so no references on the file name. thanks in advance