LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help required to code a '% of total' column

Hi folks, I looking to write code to add a % of Total column to my Pivot
table. I'm having trouble because at present I'm getting this:

Jan Feb Total
Product A Sales 100 150 250
% of Total 10% 15% 25%

Product B Sales 150 200 350
% of Total 15% 20% 35%

Product C Sales 200 200 400
% of Total 20% 20% 40%

Total Sales 450 550 1000
Total % of Total 45% 55% 100%

What I want to get is this:

Jan Feb Total % of Total
Product A 100 150 250 25.00%
Product B 150 200 350 35.00%
Product C 200 200 400 40.00%
Total 450 550 1000

My code (or a snippet of it) looks like this:

With pvtQuantities
With .PivotFields("Product")
.Orientation = 1 ' 1=Row
End With

With .PivotFields("Month")
.Orientation = 2 ' 2=Column
End With

With .PivotFields("Sales")
.Orientation = 4 ' 4=Data
End With

'.AddDataField(xlApp.ActiveSheet.PivotTables("Sale s by
Month").PivotFields("Sales"), "% of Total")
With .PivotFields("% of Total")
.Calculation =
Microsoft.Office.Interop.Excel.XlPivotFieldCalcula tion.xlPercentOfTotal
.NumberFormat = "0.00%"
End With

End With

Would appreciate if anyone can suggest where I am going wrong...

Thanks
 
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
Another VB Code Required TGV Excel Discussion (Misc queries) 7 February 7th 09 07:21 AM
VB Code Required TGV Excel Discussion (Misc queries) 3 February 6th 09 05:31 PM
VB code to total up a column as the value change on a nother Fernando[_2_] Excel Programming 2 January 24th 05 09:03 PM
VB code to total up a column as the value change on another Fernando[_2_] Excel Programming 0 January 24th 05 07:33 PM
Code required please Neal Excel Programming 2 January 24th 05 05:27 AM


All times are GMT +1. The time now is 03:02 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"