1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Quản trị mạng >

Table 20-2. Members of the PivotTable Object

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.72 MB, 490 trang )


where Index is either a single index (the index number of the desired field) or an array of indexes.

20.5.1.2 DataFields property

This property returns the collection of all data fields, using the syntax:



PivotTableObject.DataFields

Alternatively, we can return selected data fields using the syntax:



PivotTableObject.DataFields(Index)

where Index is either a single index (the index number of the desired field) or an array of indexes.

20.5.1.3 HiddenFields property

As we will see, a pivot field can be hidden by setting its orientation to xlHidden. The

HiddenFields property returns the collection of all hidden fields, using the syntax:



PivotTableObject.HiddenFields

Alternatively, we can return selected hidden fields using the syntax:



PivotTableObject.HiddenFields(Index)

where Index is either a single index (the index number of the desired field) or an array of indexes.

20.5.1.4 PageFields property

The PageFields property returns the collection of all page fields, using the syntax:



PivotTableObject.PageFields

Alternatively, we can return selected page fields using the syntax:



PivotTableObject.PageFields(Index)

where Index is either a single index (the index number of the desired field) or an array of indexes.

20.5.1.5 PivotFields property

The PivotFields property returns the collection of all pivot fields, using the syntax:



PivotTableObject.PivotFields

Alternatively, we can return selected pivot fields using the syntax:



PivotTableObject.PivotFields(Index)

where Index is either a single index (the index number of the desired field) or an array of indexes.

20.5.1.6 RowFields property



305



The RowFields property returns the collection of all row fields, using the syntax:



PivotTableObject.RowFields

Alternatively, we can return selected row fields using the syntax:



PivotTableObject.RowFields(Index)

where Index is either a single index (the index number of the desired field) or an array of indexes.

20.5.1.7 VisibleFields property

The VisibleFields property returns the collection of all visible fields, using the syntax:



PivotTableObject.VisibleFields

Alternatively, we can return selected visible fields using the syntax:



PivotTableObject.VisibleFields(Index)

where Index is either a single index (the index number of the desired field) or an array of indexes.



20.5.2 Totals-Related Members

The PivotTable object has two properties that affect the display of totals.

ColumnGrand property (R/W Boolean)

When this property is True, the PivotTable shows grand column totals.

RowGrand property (R/W Boolean)

When this property is True, the PivotTable shows grand row totals.

To illustrate, referring to the pivot table in Figure 20-6, the code:

ActiveSheet.PivotTables("Sales&Trans"). _

ColumnGrand = False

ActiveSheet.PivotTables("Sales&Trans"). _

RowGrand = False



produces the pivot table in Figure 20-9, with no grand totals.

Figure 20-9. No grand totals



306



AM

FL

Y



We can also suppress the display of individual pivot-field totals, such as the totals for Store City in

Figure 20-9. This is a property of the particular PivotField object, so we will discuss it when we

discuss this object later in the chapter. As a preview, however, the display of field totals is

governed by the Subtotals property of the PivotField object. For instance, the following code turns

off all field totals in Figure 20-9:



TE



Dim i As Integer

For i = 1 To 12

ActiveSheet.PivotTables("Sales&Trans"). _

PivotFields("Store City").Subtotals(i) = False

Next



(There are 12 types of totals, and we must turn them all off.) This produces the pivot table in

Figure 20-10.

Figure 20-10. No totals at all



307 ®

Team-Fly



20.5.3 Returning a Portion of a PivotTable

Several of the members of the PivotTable object are designed to return a portion of the pivot table

as a Range object. They are as follows.

20.5.3.1 ColumnRange property

This property returns a Range object that represents the column area in the pivot table. Figure 2011 illustrates the column range.

Figure 20-11. The ColumnRange range



20.5.3.2 DataBodyRange property

This property returns a Range object that represents the PivotTable's data area. Figure 20-12

shows the results of selecting the DataBodyRange.

Figure 20-12. The DataBodyRange range



20.5.3.3 DataLabelRange property



308



Xem Thêm
Tải bản đầy đủ (.pdf) (490 trang)

×