Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
hiunnati
 
Posts: n/a
Default Pivot tables - Sum instead of Count


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


--
hiunnati
  #2   Report Post  
Posted to microsoft.public.excel.misc
Debra Dalgleish
 
Posts: n/a
Default Pivot tables - Sum instead of Count

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
hiunnati
 
Posts: n/a
Default Pivot tables - Sum instead of Count


Thanks!!!
It works :)

Debra Dalgleish Wrote:
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



--
hiunnati
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot tables: SUM not COUNT!!!!!!!! Martin James Thornhill Excel Discussion (Misc queries) 1 April 25th 06 12:54 PM
Problems with updating category names in pivot tables Vladimir Excel Discussion (Misc queries) 2 November 3rd 05 12:54 PM
How do I keep file sizes small when using multiple pivot tables? jester1072 Excel Discussion (Misc queries) 2 June 6th 05 06:43 PM
Blank Cells in Pivot Tables Greg Excel Discussion (Misc queries) 1 March 16th 05 09:23 PM
Macro for Pivot Tables Thomas Excel Discussion (Misc queries) 1 March 15th 05 01:03 AM


All times are GMT +1. The time now is 01:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"