Sub pivotTable() intNumberOutputRows = 1 Do Until Cells(intNumberOutputRows, 1) = "" intNumberOutputRows = intNumberOutputRows + 1 Loop Application.CutCopyMode = False ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ "Data!R1C1:R" & intNumberOutputRows - 1 & "C31").CreatePivotTable TableDestination:="", TableName:= _ "PivotTable8", DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1) ActiveSheet.Cells(3, 1).Select ActiveSheet.PivotTables("PivotTable8").PivotFields("Customer Type" _ ).Subtotals = Array(False, False, False, False, False, False, False, False, False, False _ , False, False) ActiveSheet.PivotTables("PivotTable8").PivotFields("Customer Name"). _ Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _ False, False) ActiveSheet.PivotTables("PivotTable8").PivotFields("Product Category"). _ Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _ False, False) ActiveSheet.PivotTables("PivotTable8").AddFields RowFields:=Array( _ "Customer Type", "Customer Name", "Product Category"), _ ColumnFields:="Trade Date", PageFields:="Place of Purchase" With ActiveSheet.PivotTables("PivotTable8").PivotFields("Product ID") .Orientation = xlDataField .Caption = "Count of Product ID" .Function = xlCount End With ActiveCell.Cells.Select Range("D4").Select Selection.Group Start:=True, End:=True, Periods:=Array(False, False, False, _ False, True, False, True) Cells.EntireRow.AutoFit Cells.EntireColumn.AutoFit ActiveSheet.name = "All Volume" End Sub Sub VegetablePivotTable() ActiveWorkbook.Worksheets("All Volume").PivotTables("PivotTable8").PivotCache. _ CreatePivotTable TableDestination:="", TableName:="PivotTable9", _ DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTables("PivotTable9").AddFields RowFields:=Array( _ "Customer Type", "Customer Name", "Product Category"), ColumnFields _ :="Purchase Date", PageFields:="Place of Purchase" With ActiveSheet.PivotTables("PivotTable9").PivotFields("Product ID") .Orientation = xlDataField .Caption = "Count of Product ID" .Function = xlCount End With ActiveSheet.PivotTables("PivotTable9").PivotFields("Customer Type" _ ).Subtotals = Array(False, False, False, False, False, False, False, False, False, False _ , False, False) ActiveSheet.PivotTables("PivotTable9").PivotFields("Customer Name"). _ Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _ False, False) ActiveSheet.PivotTables("PivotTable9").PivotFields("Product Category"). _ Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _ False, False) ActiveWorkbook.ShowPivotTableFieldList = True ActiveCell.Columns("A:A").EntireColumn.EntireColumn.AutoFit ActiveCell.Cells.Select ActiveCell.Cells.EntireColumn.AutoFit ActiveCell.Cells.EntireRow.AutoFit ActiveCell.Offset(8, 0).Range("A1").Select With ActiveSheet.PivotTables("PivotTable9").PivotFields("Product Category") .PivotItems("Meat").Visible = False .PivotItems("Fruits").Visible = False End With ActiveCell.Cells.Select ActiveCell.Cells.EntireColumn.AutoFit ActiveCell.Offset(23, 14).Range("A1").Select Cells.EntireRow.AutoFit Cells.EntireColumn.AutoFit ActiveSheet.name = "Vegetable Volume" Sheets("Vegetable Volume").Select Range("A1").Select End Sub