In the last few days I’ve been asked a few questions by work colleagues regarding the visibility of sheets:
- This cell references a sheet, why I can’t find the sheet?
- Is it possible to unhide multiple sheets at the same time?
So, let’s take a look the process of hiding, unhiding and making sheets invisible.
Basic hiding and unhiding sheets:
You are probably familiar with the process of hiding and unhiding sheets.
Right-click the tab at the bottom and select “Hide” to hide a sheet.
To unhide right click on a worksheet tab at the bottom, select Unhide from the menu. A list of hidden sheets will appear, click the sheet you wish to unhide, then click OK.
Or you could go through the ribbon:
Home -> Cells -> Format -> Hide & Unhide -> Unhide Sheet
Applying to multiple sheets
If you want to hide multiple sheets you can use Shift or Ctrl to select a range of sheets or specific sheets. Then right-click on one of the selected tabs and select Hide.
However, unhiding multiple sheets isn’t so easy. In fact, there isn’t a method in Excel to do it. So that means you have to go through one by one, or you can use a little bit of VBA.
Insert the following code into the Visual Basic Editor
Sub AllSheetsVisible() 'Create a variable to hold the worksheet Dim Ws As Worksheet 'Loop through each worksheet in the Worksheets collection of the 'active workbook and set it to visible For Each Ws In ActiveWorkbook.Worksheets Ws.Visible = xlSheetVisible Next Ws End Sub
If you wanted to adapt the code to hide worksheets you could replace the following code. As there must be at least one visible worksheet, there is an Error Handler, so that the last visible sheet will not be hidden.
Sub AllSheetsHidden() 'This code does not actually hide all sheets, as there must be 'at least one visible sheet. The code will hide all except the last sheet. 'Create a variable to hold the worksheet Dim Ws As Worksheet 'Loop through each worksheet in the Worksheets collection of the 'active workbook and set it to visible. For Each Ws In ActiveWorkbook.Worksheets 'If there is an error do not hide the sheet On Error Resume Next Ws.Visible = xlSheetHidden On Error Goto 0 Next Ws End Sub
It is possible to have sheets which are neither visible nor hidden, these sheets are invisible (or “very hidden” as Excel calls it). This is the reason my colleague had a formula reference to a sheet which they couldn’t find, the sheet was invisible.
Worksheets in Excel can have 3 states of visibility: Visible, Hidden and Very Hidden.
- Visible = You can see the worksheet
- Hidden = You can’t see the worksheet, but it is listed as a hidden workbook
- Very Hidden = You can’t see the worksheet and it is not listed as a hidden workbook (i.e. it is “invisible”, unless you use VBA or the VBA Editor)
To make a sheet Invisible use you can replace this line of code:
Ws.Visible = xlSheetHidden
With this one:
Ws.Visible = xlSheetVeryHidden
Changing the status of a single sheet
If you know the names of your worksheets you can change their visibility status by using their individual sheet names in the VBA code.
Sub ChangeSheetVisiblity Activeworkbook.Sheets(“[Insert Sheet Name]”).Visible = xlVeryHidden End Sub