Hello,

I have recorded the macro below but was hoping to get some help with it. Basically, I am tweaking the Value section of a pivot table when the user presses a button (removing units as the value and substituting it with orders for instance). My issue is that I will not always be substituting the "Sum of Non-Dup Containers" as in the example below. It may read "Sum of Non-Dup Units" or "Sum of Non-Dup Orders" for instance. Is there a way I can tweak this code so that it replaces whatever is in the values section with the command regardless of what it reads? There should only ever be one value at any given point.

Please let me know if that's clear. Any help is appreciated!



Sub Units()
'
' Units Macro
'


'
Range("A10").Select
ActiveSheet.PivotTables("PivotTable3").PivotFields("Sum of Non-Dup Containers"). _
Orientation = xlHidden
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Non-Dup Units"), "Count of Non-Dup Units", xlCount
With ActiveSheet.PivotTables("PivotTable3").PivotFields( _
"Count of Non-Dup Units")
.Caption = "Sum of Non-Dup Units"
.Function = xlSum
End With
Range("A1").Select
End Sub