You are currently offline, waiting for your internet to reconnect

How to hide sheets and use xlVeryHidden constant in a macro

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article was previously published under Q213609
For a Microsoft Excel 97 and earlier and Microsoft Excel 98 and earlier version of this article, see 142530.
In Microsoft Excel, you can hide sheets in a workbook so that a user cannot see them. You can hide any type of sheet in a workbook, but you mustalways leave at least one sheet visible.

Hiding a Sheet Using Menu Commands

To hide a sheet, point to Sheet on the Format menu, and then click Hide. To unhide a sheet, point to Sheet on the Format menu, and then click Unhide. Select the appropriate sheet and then click OK.

NOTE: You cannot hide module sheets because they appear in the Visual Basic Editor.

Hiding a Sheet with a Visual Basic Macro

You can also hide or unhide a sheet using a Microsoft Visual Basic forApplications macro or procedure. When you use Visual Basic code, you canuse the xlVeryHidden property to hide a sheet and keep the Unhide dialog box from listing it. When you do this, the only way to make the sheet visible again is to create another Visual Basic macro.

In a Visual Basic macro, use the Visible property to hide or unhide a sheet. You can set the Visible property to True, False, or xlVeryHidden. True and False have the same effect as using the Unhide or Hide menu commands. The xlVeryHidden argument hides the sheet and also keeps the Unhide dialog box from displaying it.

Sample Visual Basic Code

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following samples show you how to use the Visible property of aSheet object.
   Sub UnhideSheet()       Sheets("Sheet1").Visible = True    End Sub				
    Sub HideSheet()       Sheets("Sheet1").Visible = False    End Sub				
The following sample illustrates how to use the xlVeryHidden argument of the Visible property to hide a worksheet:

    Sub VeryHiddenSheet()       Sheets("Sheet1").Visible = xlVeryHidden    End Sub				
XL2000 XL2003 XL2007

Article ID: 213609 - Last Review: 01/24/2007 02:53:20 - Revision: 5.1

Microsoft Office Excel 2007, Microsoft Office Excel 2003, Microsoft Excel 2000 Standard Edition, Microsoft Excel 2002 Standard Edition

  • kbdtacode kbhowto kbprogramming KB213609