[ABC home]    [ABC Archives by Issue]   [ABC Archives by Author]  [Search]  [Privacy]

 

ABC Home Page
ABC Home

 

Advertise in ABC

 

Learn more
about
Ray Blake
Ray Blake

Read
Ray's Archives

Ray's Archives

Ray's
Website
Ray's Website, GR Business Process Solutions

 

 

ABC ~ All 'Bout Computers
The Online Web-azine for Computer Enthusiasts
-- brought to you by
Visit Linda's Computer Stop

contents page for this issue

Unhiding Multiple Worksheets in Excel
~~Ray Blake,
GR Business Process Solutions

Two ways to overcome Excel’s insistence that you unhide your hidden sheets one at a time, culminating in a very useful free add-in.

Excel lets you hide worksheets within a workbook, which can be handy if – for instance – you want to conceal the workings of your spreadsheets, or want to keep the user interface clean and simple.

Fortunately, you can also unhide these sheets, but ONLY ONE AT A TIME. This can be a major frustration if you need to do this a lot, particularly since the command is buried a couple of levels down in the menu structure.

I have developed two VBA solutions to this problem, depending on the level of fine control you want over the operation. First of all, there is the quick and dirty method. This macro will simply cycle through all the worksheets in the current workbook and make them all visible:

Sub UnHideAllSheets()

     For Each c In Sheets

          c.Visible = True

     Next c

End Sub

The second method, however, is a little more elaborate and provides direct control over the hide status of each sheet. It runs from the following userform, which I have called frmSelect:

Unhide userform

By selecting sheets in either listbox and clicking the appropriate button, the selected sheets will be hidden or unhidden as desired. Standard Windows multi-select functionality is enabled.

There is code in a normal module which sets up and opens the form:

Public arrSheets() As Boolean

 

Sub HiddenSheetForm()

     ReDim arrSheets(Sheets.Count)

     frmSelect.lbHidden.Clear

     frmSelect.lbNon.Clear

          For i = 1 To Sheets.Count

               arrSheets(i) = Sheets(i).Visible

               If arrSheets(i) Then

                   frmSelect.lbNon.AddItem Sheets(i).Name

          Else

               frmSelect.lbHidden.AddItem Sheets(i).Name

          End If

     Next i

     frmSelect.Show

End Sub

There is also code behind the form as follows:

Private Sub btnHide_Click()

     For i = 0 To lbNon.ListCount - 1

          If lbNon.Selected(i) = True Then

               For j = 1 To Sheets.Count

                    If Sheets(j).Name = lbNon.List(i) Then

                         arrSheets(j) = False

                         Sheets(j).Visible = False

                    End If

                Next j

           End If

     Next i

     UpdateForm

End Sub

 

Private Sub btnUnhide_Click()

     For i = 0 To lbHidden.ListCount - 1

          If lbHidden.Selected(i) = True Then

               For j = 1 To Sheets.Count

                    If Sheets(j).Name = lbHidden.List(i) Then

                         arrSheets(j) = True

                         Sheets(j).Visible = True

                    End If

               Next j

          End If

     Next i

     UpdateForm

End Sub

 

Sub UpdateForm()

     lbNon.Clear

      lbHidden.Clear

      For i = 1 To Sheets.Count

           arrSheets(i) = Sheets(i).Visible

      If arrSheets(i) Then

            frmSelect.lbNon.AddItem Sheets(i).Name

      Else

           frmSelect.lbHidden.AddItem Sheets(i).Name

      End If

   Next i

End Sub

 

Private Sub btnClose_Click()

     Me.Hide

End Sub

You can download this code packaged as an addin with its own toolbutton from www.grbps.com/addhid.htm.

Ray Blake lives in England and spent 15 years training people in the financial services industry there. He had always used PCs in his work, and gradually realized he might make a career out of them. He and his business partner set up GR Business Process Solutions (www.grbps.com) which specializes in innovative IT to support knowledge testing and skills assessment. Although he spends a lot of time these days developing in VB and Access, Excel remains his favorite development tool, because, as he says, 'It can do everything; there's no computer application you can think of that you couldn't develop in Excel.'

 


 Support ABC

 

Linda's Ebooks
Ebooks on Access, Excel, Outlook, PowerPoint, Publisher, and Word

Linda's CD
Order Linda's CD and learn all of the Office programs

The Newbie Club
Learn all about computers the easy way

Online classes
at Eclectic Academy
 Instructor led online courses at Eclectic Academy

My Newest Book
Excel 2003 Study Guide

published by Wiley
get it at Amazon,
at Barnes & Noble,
or at Borders

FrontLook
Add-ins
& Screen Capture

Great FrontPage addins and other software

WinBackup
SpeedUpMyPC
WinTasks5Pro

great Windows utilities


 

 

 Privacy Policy, Disclaimer, and Legal Stuff
This page was last updated on Monday, December 31, 2007 . copyright © 2000 - 2008, Linda F. Johnson, Linda's Computer Stop, ABC ~ All 'Bout Computers. All rights reserved.
[SEARCH THIS SITE]