?
Solved

Unhide or Make Visible  All Worksheets

Posted on 2010-11-16
9
Medium Priority
?
373 Views
Last Modified: 2012-05-10
Is there a phrase that will make all Worksheets within a Workbook visible, or is there a Sub that will put all worksheets in an array and then make the array visible.

I have a number of  ways, or code snippets, in using loops that will make each worksheet visible, but with more emphasis being placed on the efficiency of code, is there a way to use one line that selects all worksheets and sets their value to xlsheetVisibel or .Visible = true.

Or, if a Sub was placed at the beginning of a procedure and did a count of the worksheets, could that me a method to use later on in setting them to visible.

Thanks,

Cook
0
Comment
Question by:Cook09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 24

Expert Comment

by:broomee9
ID: 34147694
You can either loop through all the worksheets and protect them one at a time, or you can store all the worksheets in an array, which you will still have to loop through to protect them all.

Alternatively, you can add a sheet event that once a sheet is selected it gets formatted.  But that even would have to be for every sheet.

So you'll have to loop through the sheets one way or another.
0
 

Author Comment

by:Cook09
ID: 34147724
So, even though Excel has a way of selecting all of the worksheets within a workbook,

"Worksheets.Select", there is no way making use of that to add a method, like Visible to them?
0
 
LVL 24

Accepted Solution

by:
broomee9 earned 2000 total points
ID: 34147806
If you want to make them all invisible at once, then you can do something like this:
Worksheets(Array("Sheet1", "Sheet2")).Visible = xlHidden
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34147863
But then you have to know all the names. Looping isn't hard you just do.
Dim s As Worksheet

For Each s In Worksheets
  s.Visible = xlSheetVisible
Next

Open in new window

0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34147872
It is not really inefficient to do it that way.
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34147885
If it looks like it's running slow it's because of the i/o not the code. Turn screen updating off and back on.
Applicaton.ScreenUpdating = False
Dim s As Worksheet

For Each s In Worksheets
  s.Visible = xlSheetVisible
Next

Applicaton.ScreenUpdating = True

Open in new window

0
 

Author Comment

by:Cook09
ID: 34148498
I just got back...but shouldn't I be able to set a variable...arrVariable =worksheets(array...)  and then use that variable name to set the visible or hidden attribute?   arrVariable.visible=xlsheetvisible ?
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34148716
If you could do that (and I don't think you can) it would do the same loop in the background so it isn't any more efficient. Running methods off arrays is the exact same as writing a loop.
0
 

Author Closing Comment

by:Cook09
ID: 34149797
Even though I didn't get the answer I was looking for, yet it came close.

The best I could come up with, with each element as the sheet name was:

Sheets(arrVar(2)).Visible = True

I tried to find a way of changing all of the arrVar's at once, but was unsuccessful., although it would seem as if there should be .

Thanks for the input.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question