Adding VBA hyperlink to a cell on another sheet

chickenchester

New Member
Joined
Jun 30, 2017
Messages
16
Below is a piece of my code. Unfortunately, I'm not able to download onto this computer, therefor I can't upload files to share. I'll try my best to explain. I have a spreadsheet that contains a Summary tab. One macro will create new tabs. On those, I have a cell with the title. The Summary tab has a cell that says QTS. What I want is for that cell to point to the cell that has the title on the other sheet using a vba hyperlink. IE Go to the Summary tab, select QTS, hyperlink takes me to the new sheet to the cell that says the title. I hope this makes sense. I am still newer to VBA. Thank you!


Top of my code:
Sub test4()
Dim sh1 As Worksheet, newSh As String
Dim rngFinalRow As Range, newQTSSheet As Worksheet, newUATSheet As Worksheet
Dim indexRow As Integer

Set sh1 = Sheets("TRM Summary")

Range("B" & indexRow).Select I used the blue text as the row moves down with each new line insert.
sh.hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'newUATSheet'!A1", TextToDisplay:="QTS"
This was my attempt to change the code in red below to make it go to the new tab.
Range("C" & indexRow).Select
ActiveSheet.hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'UAT Test Cases Sample (2)'!A1", TextToDisplay:="UAT"
When I use the text in red, it does take me to the tab name. The problem is that if I change the tab name, the code no longer works. As a result, I used a cell on that tab that won't change.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top