The Custom View Object

The CustomViews property returns the CustomViews collection. Each CustomView object in this collection represents a custom view of the workbook. CustomView objects are pretty straightforward, so we will just consider an example. Look at the sheet shown in Figure 17-6.

Figure 17-6. Example of the CustomView object

A

B

C

1

Ytar

ItemCode

Quantity

2

1997

20

30

3 j

1997

50

60

4

1997

13

9G

5 I

199S

15

56

6

1998

se

67

7

1993

44

7&

Now suppose we use the Autofilter command to filter on the year, as shown in Figure 17-7.

Figure 17-7. A filtered view

5

A

B

C

Year*] it^mCoQ Qua nth | :39o 15 56

6

1998

3S

67

Iv

1998

¿4

78

The following code will give this custom view the name View1998: ThisWorkbook.CustomViews.Add "View1998" Now we can display this view at any time with the code:

ThisWorkbook.CustomViews!View1998.Show or:

strView = "View1998"

ActiveWorkbook.CustomViews(strView).Show

0 0

Post a comment