Worksheet Object

Description

Represents a worksheet. The Worksheet object is a member of the Worksheets collection. The Worksheets collection contains all the Worksheet objects in a workbook.

Using the Worksheet Object

The following properties for returning a Worksheet object are described in this section:

  • Worksheets property
  • ActiveSheet property
Worksheets Property

Use Worksheets(index), where index is the worksheet index number or name to return a single Worksheet object. The following example hides worksheet one in the active workbook.

Worksheets(1).Visible = False
The worksheet index number denotes the position of the worksheet on the workbook's tab bar. Worksheets(1) is the first (leftmost) worksheet in the workbook, and Worksheets(Worksheets.Count) is the last one. All worksheets are included in the index count, even if they're hidden.

The worksheet name is shown on the tab for the worksheet. Use the Name property to set or return the worksheet name. The following example protects the scenarios on Sheet1.

Worksheets("Sheet1").Protect password:="drowssap", scenarios:=True
The Worksheet object is also a member of the Sheets collection. The Sheets collection contains all the sheets in the workbook (both chart sheets and worksheets).

ActiveSheet Property

When a worksheet is the active sheet, you can use the ActiveSheet property to refer to it. The following example uses the Activate method to activate Sheet 1, sets the page orientation to landscape mode, and then prints the worksheet.

Worksheets("Sheet1").Activate
ActiveSheet.PageSetup.Orientation = xlLandscape
ActiveSheet.PrintOut
Properties

Application property, AutoFilterMode property, Cells property, CircularReference property, CodeName property, Columns property, Comments property, ConsolidationFunction property, ConsolidationOptions property, ConsolidationSources property, Creator property, DisplayPageBreaks property, DisplayRightToLeft property, EnableAutoFilter property, EnableCalculation property, EnableOutlining property, EnablePivotTable property, EnableSelection property, FilterMode property, HPageBreaks property, Hyperlinks property, Index property, Name property, Names property, Next property, Outline property, PageSetup property, Parent property, Previous property, ProtectContents property, ProtectDrawingObjects property, ProtectionMode property, ProtectScenarios property, QueryTables property, Range property (Application, Range, or Worksheet object), Rows property, ScrollArea property, Shapes property, StandardHeight property, StandardWidth property, TransitionExpEval property, TransitionFormEntry property, Type property, UsedRange property, Visible property, VPageBreaks property.

Methods

Activate method, Calculate method, ChartObjects method, CheckSpelling method, CircleInvalid method, ClearArrows method, ClearCircles method, Copy method, Delete method, Evaluate method, Move method, OLEObjects method, Paste method (Worksheet object), PasteSpecial method (Worksheet object), PivotTables method, PivotTableWizard method, PrintOut method, PrintPreview method, Protect method, ResetAllPageBreaks method, SaveAs method, Scenarios method, Select method, SetBackgroundPicture method, ShowAllData method, ShowDataForm method, Unprotect method.

Events

Activate event, BeforeDoubleClick event, BeforeRightClick event, Calculate event, Change event, Deactivate event, SelectionChange event.