Hide & Unhide Sheets Using Image or Icon

KingOfKings31

New Member
Joined
Jul 2, 2018
Messages
9
Hi there. I've recently created a workbook for work that contains a dashboard along with other sheets that contain the data that feeds the dashboard. On the dashboard itself, I want to use an icon/image as a button to unhide a specific sheet in the workbook that's hidden, but also have the sheet re-hide itself when the page is clicked off of or when a icon/image button on that page is clicked. I know VBA code will be needed, but I just dont know the code to make this happen. Any and all help will be appreciated!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Put this script in your Button or image on your Dashboard:
You need to enter a sheet number like 5 or 4 or 14

Code:
Sub Unhide_Sheet()
'Modified 7/2/2018 11:00 PM  EDT
Dim ans As Long
ans = InputBox("Enter Sheet number to unhide", "UnHideMe", "3")
Sheets(ans).Visible = True
End Sub


To hide your sheet when you exit your sheet you need to:

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Deactivate()
Me.Visible = xlSheetHidden
End Sub
 
Last edited:
Upvote 0
Thank you for the quick reply. I forgot to mention that with the button, I want it to act like a hyperlink. So on button/image click, I want it to be able to unhide the hidden sheet, and go directly there with the a return button that will go back to the dashboard and rehide the sheet.
 
Upvote 0
Hyperlink to Hidden Sheet using Icon/Image VBA code

Hi there. I've recently created a workbook for work that contains a dashboard along with other sheets that contain the data that feeds the dashboard. On the dashboard itself, I want to use an icon/image as a button to act as a hyperlink and unhide a specific sheet in the workbook that's hidden and go directly to that sheet, but also have the sheet re-hide itself when the page is clicked off of or when a icon/image button on that page is clicked returning back to the dashboard. I know VBA code will be needed, but I just dont know the code to make this happen. Any and all help will be appreciated!
 
Upvote 0
Well we need a button to click on so you tell script what sheet to unhide.
We do not need a Hyperlink if we are using a button.
I can tell the script to unhide the sheet and go to that sheet.


Try this:
Code:
Sub Unhide_Sheet()
'Modified 7/2/2018 11:31 PM  EDT
On Error GoTo M
Dim ans As Long
ans = InputBox("Enter Sheet nunber to unhide", "UnHideMe", "3")
Sheets(ans).Visible = True
Application.Goto Sheets(ans).Range("A1")
Exit Sub
M:
MsgBox "That sheet number does not exist"

End Sub
 
Upvote 0
To do this part:

with the a return button that will go back to the dashboard and rehide the sheet.

You will need to have a button on every sheet and a script in that button.
You would need to make all these buttons and then enter a script in each button.

So what was wrong with my plan.
When you select another sheet the previous sheet is hidden

And if you wanted this to work on all sheets we would only need to one script and not a script for all sheets.

There are always a lot better ways to do things.
Needing buttons on 75 different sheets will be a lot of work for you.
I could write the script so when you exit the sheet the sheet is hidden and you are taken back to the dashboard sheet.

Tell me the name of the dashboard sheet.
 
Upvote 0
The main page that will house the icon/button is called "Dashboard". The only sheet that I need to have linked to that button is called "Alarm_Descriptions".

So that means I only need two buttons total. One for the dashboard that unhides and launches the "Alarm_Descriptions" sheet and a return button that will rehide the "Alarm_Descriptions" sheet and return to the dashboard sheet
 
Upvote 0
You will need these two scripts:

Code:
Sub Unhide_Sheet()
'Modified 7/3/2018 12:25 AM  EDT
Sheets("Alarm_Descriptions").Visible = True
Application.Goto Sheets("Alarm_Descriptions").Range("A1")
End Sub


Code:
Sub Hide_Me()
'Modified 7/3/2018 12:25 AM  EDT
ActiveSheet.Visible = False
Application.Goto Sheets("Dashboard").Range("A1")
End Sub
 
Upvote 0
Re: Hyperlink to Hidden Sheet using Icon/Image VBA code

If you insist on the hyperlink then
Create your button or image or what ever.
Right click on the button and you should see add Hyperlink and you should see how to do it.
But then you will have to put a script in the button that will hide or unhide the sheet.
A Hyperlink in itself cannot hide or unhide a sheet.
I have provided code in previous postings showing how to hide or unhide sheets.

It's very simple code like this:
Sheets("Jack").Visible=True
Or
Sheets("Jack").Visible=False
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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