Class CustomViews (Excel VBA)

A collection of custom workbook views. To use a CustomViews class variable it first needs to be instantiated, for example


Dim cvs as CustomViews
Set cvs = ActiveWorkbook.CustomViews

For Each

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


Dim cvw As CustomView
For Each cvw In ActiveWorkbook.CustomViews
	
Next cvw

Add

Creates a new custom view.

Add (ViewName, PrintSettings, RowColSettings)


Dim strViewName As String: strViewName = 
Dim cvw As CustomView
Set cvw = ActiveWorkbook.CustomViews.Add(ViewName:=strViewName)

Arguments

The following argument is required

ViewName (String) - The name of the new view.

Optional arguments

The following arguments are optional

PrintSettings (Boolean) - True to include print settings in the custom view.

RowColSettings (Boolean) - True to include settings for hidden rows and columns (including filter information) in the custom view.

Count

Returns a Long value that represents the number of objects in the collection.


Dim lngCount As Long
lngCount = ActiveWorkbook.CustomViews.Count

Item

Returns a single object from a collection.

Item (ViewName)

ViewName: The name or index number for the object.


Dim cvw As CustomView
Set cvw = ActiveWorkbook.CustomViews(ViewName:="Current Inventory")