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.
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.