Ben
Ben

Reputation: 47

Adding a link to a worksheet to a cell in a different worksheet within the same workbook

see Title. I want to add a hyperlink (which directs to a chart-sheet) to a cell in an index sheet so the user can click on the link in the index sheet and it takes them to the chart.

I've tried listing the entire path after Address:=, so Address:=ThisWorkbook.("Charts Index"), I've tried setting the path equal to a string and variant, I've tried replicating nearly every similar problem on the internet. I've tried using .Hyperlinks and .SubAddressin multiple different way, etc.

Set newWs = ThisWorkbook.Charts.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count))

Dim index_ws As Worksheet
Set index_ws = ThisWorkbook.Worksheets("Charts Index")

Sheet3.define_emptyRow

With index_ws
    .Cells(emptyRow, 1) = chTitle_textB.Value
    .Cells(emptyRow, 2) = shName_textB.Value
    .Hyperlinks.Add Anchor:=.Cells(emptyRow, 3), _
    Address:="", SubAddress:=newWs, _
    TextToDisplay:="see Chart"
End With

I want this code to add a hyperlink to my index page and when I click on it, I want it to take me to the chart.

Upvotes: 0

Views: 132

Answers (2)

Veri
Veri

Reputation: 9

I hope I understand your question correctly but have you tried using the "Insert hyperlink" tool (button) provided by Excel? There is a menu option called "Place in This Document" where you can select the sheet or defined name you want to link it to (as a hyperlink) within the same workbook. You can specify the cell, the worksheet, or even the defined name.

Here is a screen shot of how it looks like: Insert Hyperlink Menu

I hope this helps! It is not a VBA code but I thought it might be what you are looking for (with a simple solution).

V

Upvotes: 0

user11509084
user11509084

Reputation:

Manually,

Insert > Link > Place in this document

via VBA

.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
 "Sheet1!R1C1", TextToDisplay:="Click Me"

(Replace Selection with a cell reference.)

Upvotes: 1

Related Questions