Dear Experts,

Need help in creating vba for pivot tables and slicer.

I have multiple pivot tables in workbook and i want to change its value field setting simultaneously with one slicer. I got below code from google search and its worked for me. but it can be use for only one pivot table.
I want it to use for multiple x pivot tables and on multiple sheets. I want to use two value fields for each pivot table (Acv in Crs and ACV in USD Mn)



https://sites.google.com/site/e90e50...-or-powerpivot

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)

Dim ptMain As PivotTable
Dim pfMeasure As CubeField
Dim i As Long

On Error GoTo Errorhandler

Set ptMain = ThisWorkbook.Worksheets("Pivot").PivotTables("PivotTable1")

For Each pfMeasure In ptMain.CubeFields
If pfMeasure.Orientation = xlDataField Then
pfMeasure.Orientation = xlHidden
End If
Next

i = 0
Do While [choice].Offset(i, 0).Value <> ""
ptMain.AddDataField ptMain.CubeFields("[Measures].[" & [choice].Offset(i, 0).Value & "]")
i = i + 1
Loop

Exit Sub

Errorhandler:
Debug.Print Now(), Err.Description

End Sub

kindly help
Thanks you in advance