Link to another tab from cell name

Chewyhairball

Active Member
Joined
Nov 30, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
Hi

I am looking to try and create a link to another tab in the worksheet. This tab is named in column E of my table.

What I would like is to be able to double click on any cell in a row and to be taken to the Tab named in column E for that row.
Eg. If i click anywhere on item 5 row I would like to be taken to the tab name in column E, in this case Tab3.....the data changes so static hyperlinks wont work.
thanks in advance :)

Item 10.10030Subject1Tab1x0wrtx
Item20.20050Subject2Tab2x0.1wrtx
Item 30.20090Subject3Tab1r0.1XX
Item411Subject4Tab1r0.1XX
Item50.20070Subject5Tab3Ps0.1XX
Item60.20Subject6Tab6Ps1xx
Item70.10180Subject7Tab7Pf0.2xttr
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Right-click on the sheet tab name at the bottom of your screen, select "View Code", and paste this code in the VB Editor window that pops up.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    Dim sh As String
    
'   Get sheet name from column E of active row
    sh = Cells(Target.Row, "E").Value
    
'   Check for value
    If sh = "" Then
        MsgBox "You have selected a row with no sheet name in column E", vbOKOnly, "ERROR!"
    Else
'       Jump to tab name in column E
        On Error GoTo err_chk
        Sheets(sh).Select
        On Error GoTo 0
    End If
    
    Exit Sub
    
err_chk:
    If Err.Number = 9 Then
        MsgBox "No sheet in workbook with name " & sh, vbOKOnly, "ERROR!"
    Else
        MsgBox Err.Number & ": " & Err.Description
    End If
    
End Sub
This should automatically do what you want as you double-click anywhere on that sheet.
 
Upvote 0
Solution
Right-click on the sheet tab name at the bottom of your screen, select "View Code", and paste this code in the VB Editor window that pops up.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   
    Dim sh As String
   
'   Get sheet name from column E of active row
    sh = Cells(Target.Row, "E").Value
   
'   Check for value
    If sh = "" Then
        MsgBox "You have selected a row with no sheet name in column E", vbOKOnly, "ERROR!"
    Else
'       Jump to tab name in column E
        On Error GoTo err_chk
        Sheets(sh).Select
        On Error GoTo 0
    End If
   
    Exit Sub
   
err_chk:
    If Err.Number = 9 Then
        MsgBox "No sheet in workbook with name " & sh, vbOKOnly, "ERROR!"
    Else
        MsgBox Err.Number & ": " & Err.Description
    End If
   
End Sub
This should automatically do what you want as you double-click anywhere on that sheet.
That is exactly what i wanted. Thank you Joe. Perfect! :)
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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