Selecting Ranges

The PivotField object has two properties related to selecting portions of the pivot table related to the field.

20.7.4.1 DataRange property

This property returns a Range object representing the value area associated with the given PivotField. To illustrate, the code:

ActiveSheet.PivotTables("Sales&Trans"). PivotFields("Store Type"). DataRange.Select results in Figure 20-26.

Figure 20-26. DataRange for Store Type

A

B

C

D

E

F

G

1

Year

(Al) ▼

2

3

Pei lod

4

Store City

Store Type

Data

1

2

3

4

5

BOSTON

Companv

Trans

28248

28714

23672

28602

6

Sai9

44 67 S

45S27

46256

46223

7

Franchise

Trans

13993

13342

■H275

13210

a

Sa:e

21315

21733

13632

l£32r;-

a

LOS ANGELES

Company

Trans

34538

35Q33

35692

3JiCC I

10

Sale

123473

129564

126340

125418

11

Franchise

Trans

7153 3

72947

75610

74392

12

Sale

262431

268274

279325

274531

13

NEW YORK

Companv

Trans

246 IS

261^14

2 7015

268ÎÎ4

14

Sale

78080

85251

¿7905

88058

15

Trans

S3 27 3

54351

51822

51218

16

Sale

176353

182461

170537

167446

20.7.4.2 LabelRange property

The LabelRange property returns a Range object that represents the label cells for the PivotField. To illustrate, the code:

ActiveSheet.PivotTables("Sales&Trans"). PivotFields("Store Type"). LabelRange.Select will select just the cell containing the button labeled Store Type in Figure 20-26.

0 0

Post a comment