Hide Sheets with a click of a button

zac_595

New Member
Joined
Sep 29, 2013
Messages
12
Hi,

I have a workbook with 13 Sheets, which is pretty much a daily report.
Sheet one is called Navigation calendar. This sheet has all the hyperlinks to navigate to each month which are the 12 sheets, Jan to Dec and are hidden. Now if I get one sheet right then the rest should work.

In the "navigational calendar" I have dates that would point out to a day which would unhide that particular sheet.
Ex: Jan 1 is hyperlinked, I click it and it unhides Sheet 2 - which is named "January". Now I have figured out the code on how to unhide while clicking the hyperlink from the parent sheet (Navigational Calendar).
The problem here is I want to create a macro, since I have buttons in the remaining 12 sheets. When I click the button "Back" or "go to navigational calendar" I want the current sheet to hide and go to the target page that it is hyperlinked to.

All the 12 sheets will be hidden, I was able to figure out the first part. Going to the Parent sheet and unhiding it by clicking the hyperlink.


Code to Unhide when clicking a hyperlink

Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Application.Goto ActiveCell, True
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).Range(MyAddr).Select
Application.Goto ActiveCell, True
End If


End Sub


for the second part I Need to run a macro to hide by clicking a button that says "BACK", which is where I am blank.

Thank you. It would be great if I could get this to work on my reports.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi Wigi,
Thanks for looking into this and thank you for guiding me through that link you provided there, but what I want is a little different here. I have shapes in the 12 sheets(Back, Next etc) which has to be hyperlinked to the parent sheet. Now each time I click on to those shapes, the sheets should hide. I just need a code for that so I can run it. I have something like this, but it does not work.

Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Worksheets("Navigational Calendar Daily").Select
Target.Parent.Worksheet.Visible = False
    Application.Goto ActiveCell, True
End Sub
Gives me an error 9 "Subscript out of range". Need something similar so that can be assigned to a shape while it hyperlinks and hides a sheet once the shape is clicked on.
 
Upvote 0
Besides that, the unhide thing works from the parent to the 12 sheets, i.e if the 12 sheets are hidden, but to hide them again is where the problem is.
Thank you.
 
Upvote 0
thank you for guiding me through that link you provided there, but what I want is a little different here.

I'm sorry to say so, but unfortunately you did not into my suggestion in the other topic: using the Worksheet_Deactivate event.

For example, for 1 of the 12 sheets to be hidden:

Code:
Private Sub Worksheet_Deactivate()
    Me.Visible = xlSheetHidden
End Sub
 
Upvote 0
Hi Wigi,
Thank you for the code and suggestions, the code works perfectly, I did look into the link that you gave regarding the topic similar to mine but that was not what i exactly wanted, and I tried using the code and that did not work as well. How ever this works fine and I am really thankful for that. Thanks again... cheers!!.
Your help is really appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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