I am trying to write a macro which would format all pivot table fields that start with "Count of" as a number and all that start with "Sum of" as currency.
This is the code I have so far, but I doesn't quite work:
Sub FormatPivot1()
Dim pt As PivotTable
Set pt = ActiveSheet.PivotTables(1)
pt.PivotFields("Count of " & "*").NumberFormat = "###0"
pt.PivotFields("Sum of " & "*").NumberFormat = "$ #,##0"
Range("B26").Select
End Sub
Does anyone know the proper syntax that would make it work?
Thanks
This is the code I have so far, but I doesn't quite work:
Sub FormatPivot1()
Dim pt As PivotTable
Set pt = ActiveSheet.PivotTables(1)
pt.PivotFields("Count of " & "*").NumberFormat = "###0"
pt.PivotFields("Sum of " & "*").NumberFormat = "$ #,##0"
Range("B26").Select
End Sub
Does anyone know the proper syntax that would make it work?
Thanks