Hello all,
Currently I have the below code which is successful at formatting all the value field settings in the selected pivot table to my specified format. My goal is to be able to apply the same macro, but to the single selected value field, rather than all the value fields.
Thanks for your help!
Currently I have the below code which is successful at formatting all the value field settings in the selected pivot table to my specified format. My goal is to be able to apply the same macro, but to the single selected value field, rather than all the value fields.
Thanks for your help!
Code:
Public Sub SetDataFieldsToSum()
' Nick
Dim ptf As PivotField
With Selection.PivotTable
.ManualUpdate = True
For Each ptf In .DataFields
With ptf
.Function = xlSum
.NumberFormat = "#,##0_);[Red](#,##0)"
End With
Next ptf
.ManualUpdate = False
End With
End Sub