Create pivot automatically in all the sheets based on the data in sheets

aravindhan_31

Well-known Member
Joined
Apr 11, 2006
Messages
672
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi,

I have about 20 sheets in a workbook. I need to create pivot for all the data in each sheets. the Data, Column & Rows in pivot are same ( table contents are same for all the pivots) contents in table are different in each sheets. one sheet may have 2 rows, another sheet may have 35 rows, etc,

I have recored a macro for one sheet, do not know how to apply the same in all the sheets.

the code is
Code:
Sub pivot()
'
' pivot Macro
' Macro recorded 9/29/2008 by ml71
'
    Range("A1").Select
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        "'Dept T'!R1C1:R3C85").CreatePivotTable TableDestination:= _
        "'[pivot test.xls]Dept T'!R12C1", TableName:="PivotTable3", DefaultVersion _
        :=xlPivotTableVersion10
    ActiveSheet.PivotTables("PivotTable3").AddFields RowFields:="Supplier_Number" _
        , ColumnFields:="Item"
    ActiveSheet.PivotTables("PivotTable3").PivotFields("Total_Retail").Orientation _
        = xlDataField
    ActiveWorkbook.ShowPivotTableFieldList = True
    ActiveWorkbook.ShowPivotTableFieldList = False
    Application.CommandBars("PivotTable").Visible = False
    Range("E21").Select
End Sub

Is there a way that we run a macro, the pivot is automatically created in all the sheets, and the pivot table should appear in the existing sheet just after the data.

Arvind....
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,216,586
Messages
6,131,573
Members
449,655
Latest member
Anil K Sonawane

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