MissMaggie
New Member
- Joined
- May 29, 2017
- Messages
- 7
I am trying to write a macro to format whatever pivot table I am on in the active workbook on the active sheet that will format an individual data field that will always have the name "dollars". This is the code I have so far:
The code I have is as follows: This is try number 1
Sub format()
Try number 2, This code will change everything on the pivot table to dollars:
Sub pivotformatter()
For Each pt In ActiveSheet.PivotTables
For Each df In pt.DataFields("Dollars ")
df.NumberFormat = "$#,##0"
Next df
Next pt
End Sub
Neither of these quite do what I want, if you have any advice I would really appreciate it! Thank you!
The code I have is as follows: This is try number 1
Sub format()
Range("A3").Select
With ActiveSheet.PivotTables("PivotTable7").PivotFields("Dollars ")
.NumberFormat = "$#,##0"
End With
End Sub
With ActiveSheet.PivotTables("PivotTable7").PivotFields("Dollars ")
.NumberFormat = "$#,##0"
End With
End Sub
Try number 2, This code will change everything on the pivot table to dollars:
Sub pivotformatter()
For Each pt In ActiveSheet.PivotTables
For Each df In pt.DataFields("Dollars ")
df.NumberFormat = "$#,##0"
Next df
Next pt
End Sub
Neither of these quite do what I want, if you have any advice I would really appreciate it! Thank you!