PDA

View Full Version : [SOLVED:] Number format in Pivot Tables



Johannes
12-03-2004, 05:34 PM
I use pivot tables a lot and find Excel's default number format quite annoying. Each time i make a new table or place a new item to the data area, I need to manually change the number format.

I cannot find any place in Excel where the default settings for pivot tables can be changed, which would have been the easiest solution. However, I suspect that it might be possible to write a macro that would run through each item in the data area of the table and change the number format to my preferred settings, but I cannot figure out what the code should look like. Any creative ideas would be most welcome! Thanks in advance!

Johannes

geekgirlau
12-05-2004, 07:31 PM
This will set the number format for all pivot tables on the current sheet:


Sub FormatPivotData()
Dim pvtTable As PivotTable
Dim pvtField As PivotField
For Each pvtTable In ActiveSheet.PivotTables
For Each pvtField In pvtTable.DataFields
pvtField.NumberFormat = "#,##0.00"
Next pvtField
Next pvtTable
End Sub

Johannes
12-06-2004, 02:56 PM
Great ! Works beautifully ! Thank you !