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!!!
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Crow_23

Board Regular
Joined
Feb 17, 2005
Messages
183
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.
 

bex24

New Member
Joined
Feb 17, 2005
Messages
2
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!
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
What do you mean sometimes it works and sometimes it doesn't?

Is it causing errors or not giving the expected results?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,463
Messages
5,596,284
Members
414,051
Latest member
tabecker

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
Top