Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
LTofsrud
 
Posts: n/a
Default PivotTable Macro Reverts to Count Function

Hello,

I recorded a macro which creates a pivot table and when I create the layout
I make sure that it creates a sum result of the data. The initial creation
of the macro works great and I get the pivot table that I want. The problem
is that subsequence runs of the macro creates the same pivot table but
applies the Count function instead of the Sum. ?!?

I looked into the VB code behind but couldn't see anything that would result
in a different function being applied.

Has anyone else encountered this problem or have an idea as to how I might
be able to resolve this?

Thank you for your time.
  #2   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

If you have blank cells (seen as text) it will default to count when you
create the table

Regards,

Peo Sjoblom

"LTofsrud" wrote in message
...
Hello,

I recorded a macro which creates a pivot table and when I create the

layout
I make sure that it creates a sum result of the data. The initial

creation
of the macro works great and I get the pivot table that I want. The

problem
is that subsequence runs of the macro creates the same pivot table but
applies the Count function instead of the Sum. ?!?

I looked into the VB code behind but couldn't see anything that would

result
in a different function being applied.

Has anyone else encountered this problem or have an idea as to how I might
be able to resolve this?

Thank you for your time.



  #3   Report Post  
Ken Wright
 
Posts: n/a
Default

You can always add a bit of code to your own at the end that tidies it up
and ensures they all sum, something like

Dim pf As PivotField
For Each pf In ActiveSheet.PivotTables(1).DataFields
pf.Function = xlSum
Next pf

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"LTofsrud" wrote in message
...
Hello,

I recorded a macro which creates a pivot table and when I create the

layout
I make sure that it creates a sum result of the data. The initial

creation
of the macro works great and I get the pivot table that I want. The

problem
is that subsequence runs of the macro creates the same pivot table but
applies the Count function instead of the Sum. ?!?

I looked into the VB code behind but couldn't see anything that would

result
in a different function being applied.

Has anyone else encountered this problem or have an idea as to how I might
be able to resolve this?

Thank you for your time.



  #4   Report Post  
LTofsrud
 
Posts: n/a
Default

Thanks a lot for the responses guys; it was indeed the spaces! I can't
believe that I missed that.

Thanks again.

Lance

"Ken Wright" wrote:

You can always add a bit of code to your own at the end that tidies it up
and ensures they all sum, something like

Dim pf As PivotField
For Each pf In ActiveSheet.PivotTables(1).DataFields
pf.Function = xlSum
Next pf

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"LTofsrud" wrote in message
...
Hello,

I recorded a macro which creates a pivot table and when I create the

layout
I make sure that it creates a sum result of the data. The initial

creation
of the macro works great and I get the pivot table that I want. The

problem
is that subsequence runs of the macro creates the same pivot table but
applies the Count function instead of the Sum. ?!?

I looked into the VB code behind but couldn't see anything that would

result
in a different function being applied.

Has anyone else encountered this problem or have an idea as to how I might
be able to resolve this?

Thank you for your time.




  #5   Report Post  
Ken Wright
 
Posts: n/a
Default

Also note that spaces or text in any date fields will mean you are unable to
group that data into say Months or Quarters or years etc

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"LTofsrud" wrote in message
...
Thanks a lot for the responses guys; it was indeed the spaces! I can't
believe that I missed that.

Thanks again.

Lance

"Ken Wright" wrote:

You can always add a bit of code to your own at the end that tidies it

up
and ensures they all sum, something like

Dim pf As PivotField
For Each pf In ActiveSheet.PivotTables(1).DataFields
pf.Function = xlSum
Next pf

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03


--------------------------------------------------------------------------

--
It's easier to beg forgiveness than ask permission :-)


--------------------------------------------------------------------------

--

"LTofsrud" wrote in message
...
Hello,

I recorded a macro which creates a pivot table and when I create the

layout
I make sure that it creates a sum result of the data. The initial

creation
of the macro works great and I get the pivot table that I want. The

problem
is that subsequence runs of the macro creates the same pivot table but
applies the Count function instead of the Sum. ?!?

I looked into the VB code behind but couldn't see anything that would

result
in a different function being applied.

Has anyone else encountered this problem or have an idea as to how I

might
be able to resolve this?

Thank you for your time.








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
Function Macro for Nested IF Qaspec Excel Worksheet Functions 5 March 10th 05 07:25 PM
COUNT function and errors within it - Need some expert knowledge stu eade Excel Discussion (Misc queries) 2 February 1st 05 01:07 AM
PivotTable - Count by Month Gigi Excel Worksheet Functions 3 January 1st 05 12:30 PM
How can I use count function in excel where I have several criter. Princess V Excel Worksheet Functions 14 November 3rd 04 10:18 PM
Sum and Count Function Daniell Excel Worksheet Functions 0 November 2nd 04 12:03 AM


All times are GMT +1. The time now is 07:17 AM.

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

About Us

"It's about Microsoft Excel"