Class WorksheetView (Excel VBA)

An object that defines the behavior of a single worksheet view.

Item

To use a WorksheetView class variable it first needs to be instantiated, for example

Dim wsvw as WorksheetView
Set wsvw = ActiveWindow.ActiveSheetView

The following procedures can be used to set variables of type WorksheetView: SheetViews.Item, SheetViews.Item and Window.ActiveSheetView.

For Each

Here is an example of processing the WorksheetView items in a collection.

Dim wsvwSheetView As WorksheetView
For Each wsvwSheetView In Application.SheetViews
	
Next wsvwSheetView

SheetViews.Count

Returns the number of objects in the collection.

Dim lngCount As Long
lngCount = ActiveWindow.SheetViews.Count

SheetViews.Item

Returns a SheetView object that represents views in a workbook.

Item (Index)

Index: Index value of the view.

Dim chrvwItem As ChartView
Set chrvwItem = ActiveWindow.SheetViews(Index:=1)

DisplayFormulas

Returns or sets if formulas should be displayed or hidden in the current worksheet view.

ActiveWindow.ActiveSheetView.DisplayFormulas = True

DisplayGridlines

True if gridlines are displayed.

This property applies only to worksheets and macro sheets. This property affects only displayed gridlines. Use the PrintGridlines property to control the printing of gridlines.

ActiveWindow.ActiveSheetView.DisplayGridlines = True

DisplayHeadings

True if both row and column headings are displayed; False if no headings are displayed.

This property applies only to worksheets and macro sheets. This property affects only displayed headings. Use the PrintHeadings property to control the printing of headings.

ActiveWindow.ActiveSheetView.DisplayHeadings = True

DisplayOutline

True if outline symbols are displayed.

This property applies only to worksheets and macro sheets.

ActiveWindow.ActiveSheetView.DisplayOutline = True

DisplayZeros

True if zero values are displayed.

This property applies only to worksheets and macro sheets.

ActiveWindow.ActiveSheetView.DisplayZeros = True

Sheet

Returns the sheet name for the specified WorksheetView object.

Dim strSheet As String
strSheet = ActiveWindow.ActiveSheetView.Sheet