HI,
Can any one suggest what is wrong with below code.
It supposed to go to pivot table and select customer as per “LB_PL_Customer_re”.
LB_PL_Customer_re is a range defined in separate tab.
So if my LB_PL_Customer_re says select ABC customr then code will go to Pivot and select ABC in customer field and data will show accordingly.
But what is happening is I have a new customer (DFG)this month and same has been added in source data but not showing in Pivot table.
But when I select ABC data in “LB_PL_Customer_re” data is showing in this customer instead of DFG.
I have checked multiple times, sources has no filter,source data has been changed again but problem persist.
Please assist on this
Thanks
Can any one suggest what is wrong with below code.
It supposed to go to pivot table and select customer as per “LB_PL_Customer_re”.
LB_PL_Customer_re is a range defined in separate tab.
So if my LB_PL_Customer_re says select ABC customr then code will go to Pivot and select ABC in customer field and data will show accordingly.
But what is happening is I have a new customer (DFG)this month and same has been added in source data but not showing in Pivot table.
But when I select ABC data in “LB_PL_Customer_re” data is showing in this customer instead of DFG.
I have checked multiple times, sources has no filter,source data has been changed again but problem persist.
Please assist on this
Thanks
Code:
Sub PL_Process_CUST()
Set rng = Sheets("Cal").Range("LB_PL_Customer_re")
Set w = Sheets("Pivot")
Set P = w.PivotTables("PivotTable1")
If rng.Cells(1) = "*" Then
P.PivotFields("Customer").ClearAllFilters
ElseIf rng.Cells(1) <> "*" And rng.Cells(1) <> "" Then
With P.PivotFields("Customer")
For Each PvI In .PivotItems
Select Case PvI.Name
Case "NA"
Case Else
PvI.Visible = False
End Select
Next
For Each PvI In .PivotItems
For Each cl In rng
If UCase(PvI.Name) = UCase(cl.Value) Then PvI.Visible = True
Next
Next
End With
End If
End Sub