Excel unhide sheet named in cell

moroglu

New Member
Joined
Mar 4, 2018
Messages
2
Hi I hope you can help me with below.
In sheet2 cell B8 there's name of hidden sheet. Is there a vba I can use to unhide the sheet based on the value of this cell?

when I use below it's working
Worksheets("Template").Visible = True

but I would like to refer to cell B8, which is variable, where hidden sheetnames can be entered
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi & welcome to the board.
How about
Code:
Sheets(Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Range("B8").Value).Visible = True
change sheet name in red to suit
 
Upvote 0
Code:
Sub UnHideSheet()
Dim shtValue As String


shtValue = Sheets("Sheet2").Range("B8").Value


Worksheets(shtValue).Visible = True


End Sub
 
Upvote 0
Glad that worked for you, I was thinking if you are trying to use this across multiple sheets the previous solution will not work. You mentioned you would have "sheetnames" in Cell B8 of Sheet2.

but I would like to refer to cell B8, which is variable, where hidden sheetnames can be entered

If you want to enter multiple sheet names you could use this, enter comma separated values in Cell B8 Sheet2 and it will unhide them all.

In my example I had a workbook with 3 sheets, Sheet1, Sheet2 and Sheet3.

I hid Sheet1 and Sheet3 and then in Cell B8 of Sheet2 I entered

"Sheet1, Sheet3" and ran the following code, which unhide's Sheet1 and Sheet3

Code:
Sub UnHideSheet()
Dim shtValue As String


shtValue = Sheets("Sheet2").Range("B8").Value


Dim rawArray() As String


rawArray = Split(shtValue, ", ")


Dim index As Long
For index = LBound(rawArray) To UBound(rawArray)
    Worksheets(rawArray(index)).Visible = True
Next index


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,886
Messages
6,127,572
Members
449,385
Latest member
KMGLarson

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