Home » excel » vba – Hyperlink to Worksheet in actual Workbook

vba – Hyperlink to Worksheet in actual Workbook

Posted by: admin April 23, 2020 Leave a comment

Questions:

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.

How to&Answers:
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.

Answer:

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”

Answer:

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.

enter image description here