HI ,"
I am working with VBA excel. I am getting an error. Please help me. The error is "Unable to set the current page property of Pivot Field class"
Here is code

Sub ProcessSelectedRep()

xSelectRep = [WorkOut!A11]

Sheets("Pivot-Losses").Select
VerifyExistenceOfSelectedRepInPivot
If Not xFound Then
MsgBox "Rep: " & xSelectRep & " not found in pivot-Losses"
Sheets("Front").Select
Else
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable1").PivotFields("Rep").CurrentPage = xSelectRep
End If

Sheets("Pivot-Gains").Select
VerifyExistenceOfSelectedRepInPivot
If Not xFound Then
MsgBox "Rep: " & xSelectRep & " not found in pivot-Gains"
Sheets("Front").Select
End
Else
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable1").PivotFields("Rep").CurrentPage = xSelectRep
End If

Sheets(Array("Pivot-Losses", "Pivot-Gains")).Select
Sheets("Pivot-Gains").Activate

ActiveWindow.SelectedSheets.PrintPreview
End Sub