By just a single click, we can change pivot table field value format to any format.
Codes to change pivot table field default format to number format:
Dim pvName As String, pvfName As StringpvName = ActiveCell.PivotTable.NamepvfName = ActiveCell.PivotField.NameWith ActiveSheet.PivotTables(pvName).PivotFields(pvfName).NumberFormat = "#,##0_);[Red](#,##0)"End With
Codes to change pivot table field default format to percentage format:
Dim pName As String, pfName As StringpName = ActiveCell.PivotTable.NamepfName = ActiveCell.PivotField.NameWith ActiveSheet.PivotTables(pName).PivotFields(pfName).NumberFormat = "0%;[Red]-0%"End With
Note: Adjust .NumberFormat to your desire format.
No comments:
Post a Comment