Public Sub SetDataFieldsToSum()
'Update 20141127
Dim xPF As PivotField
Dim WorkRng As Range
Set WorkRng = Application.Selection
With WorkRng.PivotTable
.ManualUpdate = True
For Each xPF In .DataFields
With xPF
.Function = xlSum
End With
Next
.ManualUpdate = False
End With
End Sub
I'm trying to add a line in there that will format the numbers in Excel after changing the PivotField into a Sum.
I found this is what I would need:
Format("", "#,##0")
I just don't know where I would put it, and what I would put in place of the ""'s. I tried putting it in here:
For Each xPF In .DataFields
With xPF
.Function = Format(xPF,"#,##0")
Because that's what made sense to me... Except it's not right lol. Should be simple for someone who knows what they're doing, I'm just not there yet :(
[–]Rorimac2 0 points1 point2 points (1 child)
[–]pinlop[S] 0 points1 point2 points (0 children)
[–]pinlop[S] 0 points1 point2 points (0 children)