Formatting Pivot Fields and Items
Sub Add_DataField()
InputSH
Define_PivotTable
PV.AddDataField PV.PivotFields("Price"), "Count of Price", xlCount
With PV.PivotFields("Count of Price")
.NumberFormat = ".00"
.Position = 1
End With
End Sub
Sub Add_Row_Column_Fileds()
InputSH
Define_PivotTable
'PV.AddFields RowFields:="Price", Addtotable:=True
'PV.AddFields ColumnFields:="Price", Addtotable:=True
PV.AddFields ColumnFields:="Date", Addtotable:=True
End Sub
Sub Group_Date_Data()
InputSH
Define_PivotTable
With PV.PivotFields("Date")
.Orientation = xlColumnField
.Position = 2
End With
PV.PivotSelect "Date", xlLabelOnly, True
Selection.Group Start:=True, End:=True, Periods:=Array(False, False, False, _
False, False, False, True)
End Sub
Sub CalculatedField()
InputSH
Define_PivotTable
PV.CalculatedFields.Add "AfterDiscount", "=Qty *0.85", True
'PV.PivotFields("AfterDiscount").Orientation = xlDataField
With PV.PivotFields("AfterDiscount")
.Orientation = xlDataField
.NumberFormat = ".00"
End With
End Sub
Sub RefreshTable()
InputSH
Define_PivotTable
PV.RefreshTable
End Sub
Sub ChangeTheCaption()
InputSH
Define_PivotTable
PV.PivotFields("Item").Caption = "Items"
End Sub
Sub Row_and_Column_Grand()
InputSH
Define_PivotTable
'PV.RowGrand = False
'PV.ColumnGrand = False
PV.RowGrand = True
PV.ColumnGrand = True
End Sub
Sub Delete_PivotItem()
InputSH
Define_PivotTable
' Delete PivotItem
PV.PivotSelect "Banana", xlDataAndLabel, True
Selection.Delete
'PV.PivotFields("Count of Price").Orientation = xlHidden
'PV.PivotFields("Count of Price").Orientation = xldelete
End Sub