You could use code similar to this:
'==========================
Sub PivotTest()
Dim pt As PivotTable
Dim pf As PivotField
Set pt = Sheets("Summary").PivotTables("PivotTable1")
Set pf = pt.PivotFields("Duration")
With pf
.Orientation = xlDataField
.Function = xlSum
End With
End Sub
'===================
hiunnati wrote:
Hi,
What is the exact code which will give me Sum instead of Count for a
Pivot Field?
I have used following code but it gave me error
Sheets("Summary").PivotTables("PivotTable1").Pivot Fields("Duration").Orientation
= xlDataField
Sheets("Summary").PivotTables("PivotTable1").Pivot Fields("Duration").Function
= xlSum
I got the following error
Run-time error '1004'
Unable to set the Function property of the PivotField class
Can you help me?
Regards
--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html