Double-Click "Hyperlink" to Hidden Sheets

CodingMonkey

New Member
Joined
Jun 18, 2017
Messages
16
Hey All,

I've come here with a question about a code that I'm currently running to act as a method to "Hyperlink" to hidden sheets. I found the code on this forum, but it was back from 2011. The code works perfectly well until MERGED cells.

Code:
Private Sub Worksheet_Activate()    Dim sh As Worksheet
    
    For Each sh In ThisWorkbook.Sheets
        If sh.Name <> "Library" Then
            sh.Visible = xlSheetHidden
        End If
    Next sh
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Select Case Target.Address
        Case "$A$3"
            Sheets("496").Visible = True
            Sheets("496").Activate
        Case "$A$8"
            Sheets("497").Visible = True
            Sheets("497").Activate
    End Select
End Sub

Like I said, the code works perfectly unless the cell is merged. Even though the range of the cell is "A3" it won't activate the DoubleClick code. But single cells, such as A8, that are not merged work smoothly.

Is there something that I'm missing in my code to allow the code to work for merged cells?

The object of my worksheet is as follows:
>Double-click on Logbook number in specific columns (A, E, I, M, Q)
>Upon double-click: Opens hidden sheet for that specific logbook that allows user to see its Table of Contents.
>Upon clicking back to main sheet "Library": Logbook sheet reverts to hidden to avoid any clutter.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Please try this:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Dim Cel As Range
  Dim i As Range
  If Not Intersect(Target, Range("A3")) Is Nothing Then
    Cancel = True
    Sheets("496").Visible = True
    Sheets("496").Activate
    Exit Sub
  End If
  If Not Intersect(Target, Range("A8")) Is Nothing Then
    Cancel = True
    Sheets("497").Visible = True
    Sheets("497").Activate
    Exit Sub
  End If
  
End Sub
 
Upvote 0
That works perfectly. Thank you very much!

Updated Code for anyone looking into this in the future. You can add as many ranges in the 2nd portion. Just copy and paste and change appropriately.

Code:
Private Sub Worksheet_Activate()    Dim sh As Worksheet
    
    For Each sh In ThisWorkbook.Sheets
        If sh.Name <> "Library" Then
            sh.Visible = xlSheetHidden
        End If
    Next sh
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Dim Cel As Range
  Dim i As Range
  If Not Intersect(Target, Range("A3")) Is Nothing Then
    Cancel = True
    Sheets("496").Visible = True
    Sheets("496").Activate
    Exit Sub
  End If
  If Not Intersect(Target, Range("A8")) Is Nothing Then
    Cancel = True
    Sheets("497").Visible = True
    Sheets("497").Activate
    Exit Sub
  End If
  
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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