Macro - Pivot Tables

bex24

New Member
Joined
Feb 17, 2005
Messages
2
Hi there,
This is my first time trying to build a macro and I have five sheets that I am trying to create a macro for. I was going to do it as a step-by-step macro (linking them to buttons). Basically I am running a pivot table for each sheet. The problem is, I am trying to do a sum of all the values, but for whatever reason, it continues to take the "count". Do you know what I am doing wrong?

Thanks!!!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Here's a step by step. Any problems let me know and I'll do my best:

1. Start recording macro
2. Data --> Pivot table
3. Opens up the pivot table "Wizard"
4. Click Next 2 times until u get to the window that has "Layout" on the bottom left and click on this.
5. While in layout put in the column headers that you want displayed
6. Double click on the column header that has been placed into the "Data" field.
7. Click "Sum" or whatever other option you would like for it to do.
8. Hit Ok and that should do it

Try makin the macro like this and if there is any problem with my directions let me know. On same note any problem with macro post the code.
 
Upvote 0
i followed those steps - and sometimes it works and sometimes it doesn't. this is the code for the macro that didn't work:
Sub planned()
'
' planned Macro
' Macro recorded 2/18/2005 by rebeccal
'

'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"qry_RegularPARSbyRSM!R1C1:R250C12").CreatePivotTable TableDestination:="", _
TableName:="PivotTable3", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable3").AddFields RowFields:=Array("RSM", _
"PromoType", "CUS_NAME", "Par Number"), ColumnFields:=Array("Fiscal_Year", _
"Fiscal_Quarter")
ActiveSheet.PivotTables("PivotTable3").PivotFields("Planned").Orientation = _
xlDataField
End Sub

does this help?

thanks so much!
 
Upvote 0
What do you mean sometimes it works and sometimes it doesn't?

Is it causing errors or not giving the expected results?
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top