Created
April 16, 2017 16:01
-
-
Save ateneva/16e5e3fe847787e71a4e98c68113eb0e to your computer and use it in GitHub Desktop.
Change the number formatting of a PivotField
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub ChangeNumberFormats() | |
Dim Wks As Worksheet | |
Dim PT As PivotTable | |
Dim PF As PivotField | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
'written by Angelina Teneva, September 2016 | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
For Each Wks In ActiveWorkbook.Worksheets | |
For Each PT In Wks.PivotTables | |
For Each PF In PT.DataFields | |
If PF.SourceName Like "*Spend" Then | |
'comment as needed | |
PF.NumberFormat = "0.00" 'shows only two decimals | |
PF.NumberFormat = "#,###" 'shows numbers as thosands | |
PF.NumberFormat = "0,##" 'shows a leading zero in numbers smaller than a thousand | |
PF.NumberFormat = "#,##0" 'shows minus sign for negative values | |
PF.NumberFormat = "#,##0_);(#,##0)" 'shows negative numbers in brackets | |
PF.NumberFormat = "[$$-en-US]0.00" 'dollar currency symbol | |
PF.NumberFormat = "[$€-x-euro2] #,##0.00" 'euro currency symbol | |
PF.NumberFormat = "[$£-en-GB]#,##0.00" 'pound currency symbol | |
PF.NumberFormat = "0%; -0%;" 'hides zero values but keeps the negative ones | |
PF.NumberFormat = "0.0%" 'formats as % | |
End If | |
Next PF | |
Next PT | |
Next Wks | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment