This documentation is archived and is not being maintained.

How to: Hide Worksheets


Some code examples in this topic use the this or Me keyword or the Globals class in a way that is specific to document-level customizations, or they rely on features of document-level customizations such as host controls. These examples can be compiled only if you have the required applications installed. For more information, see Features Available by Product Combination.

The Visible property allows you to show or hide an existing worksheet without having to delete and recreate the sheet. If the worksheet was created at run time, you must access it through the Microsoft Office Excel 2003 Sheets collection, otherwise you can access the Microsoft.Office.Tools.Excel.Worksheet directly:

The worksheet object can be one of two types:

Using Host Items

To hide a worksheet using a Worksheet host item

  • Set the Visible property of the Sheet1 host item to the xlSheetHidden enumeration:

    Globals.Sheet1.Visible = Excel.XlSheetVisibility.xlSheetHidden;

Using Excel Objects

To hide a worksheet using the Sheets collection of the Excel Workbook

  • Set the Visible property of the worksheet to the xlSheetHidden enumeration:

    ((Excel.Worksheet) Globals.ThisWorkbook.Sheets[1])
        .Visible = Excel.XlSheetVisibility.xlSheetHidden;

See Also