Citation :
Sub TCD_CUMP()
'
' TCD_CUMP Macro
'
'
Range("A1" ).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R7225C52", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet4" ).Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1" ).PivotFields("Country" )
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1" ).PivotFields("GOLD Item Nbr" )
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1" ).PivotFields("Product" )
.Orientation = xlPageField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1" ).AddDataField ActiveSheet.PivotTables( _
"PivotTable1" ).PivotFields("Inv Qty" ), "Sum of Inv Qty", xlSum
ActiveSheet.PivotTables("PivotTable1" ).AddDataField ActiveSheet.PivotTables( _
"PivotTable1" ).PivotFields("Tot Price DZD" ), "Count of Tot Price DZD", xlCount
With ActiveSheet.PivotTables("PivotTable1" ).PivotFields( _
"Count of Tot Price DZD" )
.Caption = "Sum of Tot Price DZD"
.Function = xlSum
End With
ActiveSheet.PivotTables("PivotTable1" ).PivotFields("Sum of Tot Price DZD" ). _
Orientation = xlHidden
ActiveSheet.PivotTables("PivotTable1" ).AddDataField ActiveSheet.PivotTables( _
"PivotTable1" ).PivotFields("Tot Invoice DZD" ), "Count of Tot Invoice DZD", _
xlCount
With ActiveSheet.PivotTables("PivotTable1" ).PivotFields( _
"Count of Tot Invoice DZD" )
.Caption = "Sum of Tot Invoice DZD"
.Function = xlSum
End With
ActiveSheet.PivotTables("PivotTable1" ).PivotFields("Product" ).ClearAllFilters
ActiveSheet.PivotTables("PivotTable1" ).PivotFields("Product" ).CurrentPage = _
"CHEMICAL"
ActiveSheet.PivotTables("PivotTable1" ).PivotFields("Country" ).ClearAllFilters
ActiveSheet.PivotTables("PivotTable1" ).PivotFields("Country" ).CurrentPage = _
"ALGERIA"
Sheets("Sheet1" ).Select
End Sub
|