Class Worksheet (Excel VBA)
The class Worksheet represents a worksheet.
To use a Worksheet class variable it first needs to be instantiated, for example
Dim ws as Worksheet Set ws = ActiveSheet
The following procedures can be used to set variables of type Worksheet: Application.ActiveSheet, Chart.Next, Chart.Previous, HPageBreak.Parent, Range.Parent, Range.Worksheet, Sheets.Add, Sheets.Item, Slicer.Parent, VPageBreak.Parent, Window.ActiveSheet, Workbook.ActiveSheet, Next and Previous ....
Here is an example of processing the Worksheet items in a collection.
Dim ws As Worksheet For Each ws In Worksheets Next ws
Activate - Makes the current sheet the active sheet.
Calculate - Calculates all open workbooks, a specific worksheet in a workbook, or a specified range of cells on a worksheet, as shown in the following table.
CheckSpelling - Checks the spelling of an object.
CircleInvalid - Circles invalid entries on the worksheet.
ClearArrows - Clears the tracer arrows from the worksheet. Tracer arrows are added by using the auditing feature.
ClearCircles - Clears circles from invalid entries on the worksheet.
Copy - Copies the sheet to another location in the current workbook or a new workbook.
Delete - Deletes the object.
Evaluate - Converts a Microsoft Excel name to an object or a value.
ExportAsFixedFormat - Exports to a file of the specified format.
Move - Moves the sheet to another location in the workbook.
Paste - Pastes the contents of the Clipboard onto the sheet.
PasteSpecial - Pastes the contents of the Clipboard onto the sheet, using a specified format. Use this method to paste data from other applications or to paste data in a specific format.
PivotTables - Returns an pivottables that represents either a single PivotTable report (a PivotTable pivottables) or a collection of all the PivotTable reports (a PivotTables pivottables) on a worksheet. Read-only.
PivotTableWizard - Creates a new PivotTable report. This method doesn't display the PivotTable Wizard. This method isn't available for OLE DB data sources. Use the Add method to add a PivotTable cache, and then create a PivotTable report based on the cache.
PrintOut - Prints the object.
PrintPreview - Shows a preview of the object as it would look when printed.
Protect - Protects a worksheet so that it cannot be modified.
ResetAllPageBreaks - Resets all page breaks on the specified worksheet.
SaveAs - Saves changes to the chart or worksheet in a different file.
Select - Selects the object.
SetBackgroundPicture - Sets the background graphic for a worksheet.
ShowDataForm - Displays the data form associated with the worksheet.
Unprotect - Removes protection from a sheet or workbook. This method has no effect if the sheet or workbook isn't protected.
XmlDataQuery - Returns a Range object that represents the cells mapped to a particular XPath. Returns Nothing if the specified XPath has not been mapped to the worksheet, or if the mapped range is empty.
CircularReference returns a Range object that represents the range containing the first circular reference on the sheet, or returns Nothing if there's no circular reference on the sheet. The circular reference must be removed before calculation can proceed.
CodeName returns the code name for the object.
ConsolidationFunction returns the function code used for the current consolidation. Can be one of the constants of XlConsolidationFunction.
ConsolidationOptions returns a three-element array of consolidation options, as shown in the following table. If the element is True, that option is set.
ConsolidationSources returns an array of string values that name the source sheets for the worksheet's current consolidation. Returns Empty if there's no consolidation on the sheet.
DisplayPageBreaks true if page breaks (both automatic and manual) on the specified worksheet are displayed.
DisplayRightToLeft true if the specified worksheet is displayed from right to left instead of from left to right. False if the object is displayed from left to right.
EnableCalculation true if Microsoft Excel automatically recalculates the worksheet when necessary. False if Excel doesn't recalculate the sheet.
EnableFormatConditionsCalculation returns or sets if conditional formats occur automatically as needed.
EnableOutlining true if outlining symbols are enabled when user-interface-only protection is turned on.
EnableSelection returns or sets what can be selected on the sheet.
FilterMode true if the worksheet is in the filter mode.
Index returns a Long value that represents the index number of the object within the collection of similar objects.
MailEnvelope represents an email header for a document.
Name returns or sets a String value that represents the object name.
Next returns a Worksheet object that represents the next sheet.
Previous returns a Worksheet object that represents the previous sheet.
PrintedCommentPages returns the number of comment pages that will be printed for the current worksheet.
ProtectContents true if the contents of the sheet are protected. This protects the individual cells. To turn on content protection, use the Protect method with the Contents argument set to True.
ProtectDrawingObjects true if shapes are protected. To turn on shape protection, use the Protect method with the DrawingObjects argument set to True.
ProtectionMode true if user-interface-only protection is turned on. To turn on user interface protection, use the Protect method with the UserInterfaceOnly argument set to True.
ProtectScenarios true if the worksheet scenarios are protected.
ScrollArea returns or sets the range where scrolling is allowed, as an A1-style range reference. Cells outside the scroll area cannot be selected.
StandardHeight returns the standard (default) height of all the rows on the worksheet, in points.
StandardWidth returns or sets the standard (default) width of all the columns on the worksheet.
TransitionExpEval true if Microsoft Excel uses Lotus 1-2-3 expression evaluation rules for the worksheet.
TransitionFormEntry true if Microsoft Excel uses Lotus 1-2-3 formula entry rules for the worksheet.
Type returns an XlSheetType value that represents the worksheet type.
Visible returns or sets an XlSheetVisibility value that determines whether the object is visible.
AutoFilter - Represents autofiltering for the specified worksheet.
ChartObjects - A collection of all the ChartObject objects on the specified chart sheet, dialog sheet, or worksheet.
Comments - A collection of cell comments.
CommentsThreaded - A collection of top-level CommentThreaded objects in a Worksheet, or a collection of replies in a single threaded comment.
CustomProperties - A collection of CustomProperty objects that represents additional information. The information can be used as metadata for XML.
HPageBreaks - The collection of horizontal page breaks within the print area.
Hyperlinks - Represents the collection of hyperlinks for a worksheet or range.
ListObjects - A collection of all the ListObject objects on a worksheet. Each ListObject object represents a table on the worksheet.
Names - A collection of all the Name objects in the application or workbook.
OLEObjects - A collection of all the OLEObject objects on the specified worksheet.
Outline - Represents an outline on a worksheet.
PageSetup - Represents the page setup description.
PivotTable - Represents a PivotTable report on a worksheet.
PivotTables - A collection of all the PivotTable objects in the specified workbook.
Protection - Represents the various types of protection options available for a worksheet.
QueryTables - A collection of QueryTable objects.
Range - Represents a cell, a row, a column, a selection of cells containing one or more contiguous blocks of cells, or a 3D range.
Scenarios - A collection of all the Scenario objects on the specified worksheet.
Shapes - A collection of all the Shape objects on the specified sheet.
Sort - Represents a sort of a range of data.
Tab - Represents the tab of a chart or a worksheet.
VPageBreaks - A collection of vertical page breaks within the print area.