Hiding & Unhiding Chart Sheets in Code ???

jdowski

Board Regular
Joined
Apr 21, 2002
Messages
235
Hi Excel Experts !

Hope your Thanksgiving was good....
However, for those of us who have to work today :(
I have a question.

I have a piece of code that I have in many of my workbooks that unhides any/all hidden sheets when I run it. However, it will not unhide ChartSheets.

Can someone please tell me how to select ChartSheets in code ??

Here's my current code:

Sub Unhide()
'
Dim ws As Worksheet
Dim i As Integer
Dim myCounter As Integer

For i = 1 To Worksheets.Count
Set ws = Worksheets(i)
ws.Visible = True
myCounter = myCounter + 1
Next i

MsgBox myCounter & " sheets unhidden!"

End Sub


Thanks !!

Joe in Oxford, CT. USA. :LOL:
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Joe

Do as follows:

TO HIDE:
Sheets("Chart1").Visible = 0

TO UNHIDE
Sheets("Chart1").Visible = -1

I used the name of the sheet, but you can use its index number too.
 
Upvote 0
Robert,

So if I understand you correctly, it's my using the term "worksheets" that's causing the issue and you're telling me that I should be using "sheets" instead so it won't matter whether the sheet being selected is a worksheet or a chartsheet ??

Thanks !

J. :cool:

cmart02 said:
Joe

Do as follows:

TO HIDE:
Sheets("Chart1").Visible = 0

TO UNHIDE
Sheets("Chart1").Visible = -1

I used the name of the sheet, but you can use its index number too.
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,773
Members
449,336
Latest member
p17tootie

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