ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivottable references and values (https://www.excelbanter.com/excel-programming/358511-pivottable-references-values.html)

Geoff

Pivottable references and values
 
A pivottable produces as an example:
Company Operation Cost
thisone day 13.50

1. What syntax should I use to reference the value of 13.50?

2. When creating the pivottable how can I change this value to 0
yet leave the wsheet value unchanged?

The pivottable code yields:
Set pt = Sheets(5).PivotTables("PivotTable2")
pt.Name '= PivotTable2
pt.RowFields(2).Name '= Company
pt.RowFields(2).PivotItems(2).Name '= thisone
pt.RowFields(1).Name '= Operation
pt.RowFields(1).PivotItems(1).Name '= day
pt. ???????????? '= 13:50

In the pivotfield code:
With pt.PivotFields("Cost")
.Value = 0 ' doesn't work
.Orientation = xlDataField
.Position = 1
.Function = xlSum
.NumberFormat = "#,##0.00 "
End With

The wsheet values a
pt.PivotFields(16).Name '= Company
pt.PivotFields(32).Name '= Cost
pt.PivotFields(32).PivotItems(1).Value '= 0.00
pt.PivotFields(32).PivotItems(2).Value '= 13.50
pt.PivotFields(32).PivotItems(3).Value '= 27.00
pt.PivotFields(32).PivotItems(4).Value '= 49.50

T.I.A.

Geoff


All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com