User-defined type not defined when clicking on a Hyperlink that leads to a hidden tab

GCS1998

New Member
Joined
Sep 23, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi,
I've got a code to unhide a tab when clicking on a hyperlink, before going to the cell indicated in the hyperlink. It works but every time that I introduce a number or so in any other cell in the workbook, the error "user-defined type not defined" shows up and it's annoying.

Code are:

Tab that does no gets hidden

"
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Dim strAddress As String

strAddress = Application.WorksheetFunction.Substitute(Target.SubAddress, "'", vbNullString)
ThisWorkbook.Worksheets(VBA.Left$(strAddress, VBA.InStr(1, strAddress, "!") - 1)).Visible = xlSheetVisible
Application.EnableEvents = False
Target.Follow

End Sub
"

Tab that gets hidden after clicking hyperlink to go to the tab above
"
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Me.Visible = xlSheetHidden
End Sub
"



Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi,
Maybe it has something to do with calculate... you can try disabling automatic calculation while editing or checking for errors in worksheet.calculate event
 
Upvote 0
I can only imagine that there is other code that is being triggered. Can't see what entering a value anywhere has anything to do with following a hyperlink. Maybe I'm missing something.
 
Upvote 0
Hi,
Maybe it has something to do with calculate... you can try disabling automatic calculation while editing or checking for errors in worksheet.calculate event
CesarF, exactly, when I click on "calculate now" the error comes up. But I can't relay on leaving the sheet on manual calculations, otherwise I could forget and get the wrong number.
 
Upvote 0
I can only imagine that there is other code that is being triggered. Can't see what entering a value anywhere has anything to do with following a hyperlink. Maybe I'm missing something.
The problem is the codes for sure, because if I remove them, then no error. And this is happening since using 365.

The codes above are the same for all tabs: the first one, for tabs I don't want to hide when clicking in the hyperlink. The second one, for tabs that get hidden once click on the hyperlink that leads to the summary tab.

There are a summary tab for each year
 
Upvote 0
Put a break point on one of these subs and do whatever action triggers it. Then step through that code by pressing F8 and watch where it goes. Then you can report back and also state which line raises the error.
EDIT - that error is usually due to a missing reference. You should check those.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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