Recording Macro for Pivot Table

harinsh

Active Member
Joined
Feb 7, 2012
Messages
273
Hi Team,
Greetings!!!
In my daily job I use excel frequently and working on huge data in order to get the desire reports. I have recorded PIVOT to get the reports quickly but it is not working. I think need customize the Vba code in order to run this macro. It would work if I extract report in same sheet in a workbook but not able to extract to different sheet.
Can anyone help me in order to customize the codes and refer below codes when I recorded PIVOT table in a new sheet.
Thanks
Debug Code
ActiveWorkbook.Worksheets("By Product").PivotTables("PivotTable1").PivotCache. _
CreatePivotTable TableDestination:="Sheet3!R3C1", TableName:="PivotTable2" _
, DefaultVersion:=xlPivotTableVersion12
Sheets("Sheet3").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Product")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Customer"), "Count of Customer", xlCount
Range("C19").Select
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
It is simpler and better to create the pivot table without code, then refresh it when it needs to be updated.

ξ
 
Upvote 0
Ok...Thanks for your reply.

Is it not possible to record Pivot event in a Macro?? Even if it is simple Pivot table can we record??. Because when I record within sheet it is working fine but only not working in different sheet.

Thanks.
Harish
 
Upvote 0
Code can be recorded but extensive modification is required to make it work on anything that is not exactly the same every time - so much so that it might as well be written from scratch. And if it's exactly the same every time, not much point to it. See xenou's post!

Cliff Edwards
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,849
Members
449,194
Latest member
HellScout

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