Worksheets(mysheet).Visible=True

tanmaomao

New Member
Joined
Nov 24, 2019
Messages
6
Office Version
  1. 365
Platform
  1. Windows
smart people please help

I got from youtube this script to hyperlink hidden excel tab, however error point at "Worksheets(mysheet).Visible=True"
any ideas guys?

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
linkto=Target.SubAddress
wherebang=InStr(1,linkto,"!")
If wherebang>0 Then
mysheet=Left(linkto,wherebang-1)
Worksheets(mysheet).Visible=True
Worksheets(mysheet).Select
myaddr=Mid(linkto,wherebang+1)

Worksheets(mysheet).rang(myaddr).Select
End If
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
In the worksheet code module put this at the very top
Code:
Option Explicit
Then try and run the code. That will show you all the variables you have to define/set for that to work!
 
Upvote 0
Declaring the variables is always good practice but the code should still run without doing so.

The point of the error implies that the hyperlink is not pointing to a valid sheet (incorrect spelling) or range.

There could be other parts of the youtube video where the instructions have not been followed correctly.
 
Upvote 0
If you sheet names contain spaces, or are numerical change
mysheet=Left(linkto,wherebang-1)
to
mysheet = Replace(Left(linkto, wherebang - 1), "'", "")

You also have a typo on this line
Worksheets(mysheet).rang(myaddr).Select
 
Upvote 0
If you sheet names contain spaces, or are numerical change
mysheet=Left(linkto,wherebang-1)
to
mysheet = Replace(Left(linkto, wherebang - 1), "'", "")

You also have a typo on this line
Worksheets(mysheet).rang(myaddr).Select

Solved!Thanks!! Amezing and very helpful! (y)
Thank you very much :)
You helped me a lot!:)
 
Upvote 0
In the worksheet code module put this at the very top
Code:
Option Explicit
Then try and run the code. That will show you all the variables you have to define/set for that to work!
Thank you for helping out and provide useful codes. You guys are so kind and amezing!
 
Upvote 0
Declaring the variables is always good practice but the code should still run without doing so.

The point of the error implies that the hyperlink is not pointing to a valid sheet (incorrect spelling) or range.

There could be other parts of the youtube video where the instructions have not been followed correctly.

Thank you for offering me ideas and making suggestions. You guys are so kind and amezing!
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

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