peteruhl23
New Member
- Joined
- Mar 29, 2018
- Messages
- 2
cheers everybody,
I'm a newbie to VBA and decided to undertake a task to automate a report regarding supplier evaluation.
I have managed to automate all the actions needed to provide input data to my final excel sheet, created UserForm and ListBox and got to the point where my code copies selected items from listbox and pastes it to a new column
Anybody using my code, can select anywhere from 1-20 suppliers (that is 1-20 items from the listbox). Depending on their selection, I need my code to take the selection user made and filter my PivotTable based on that.
Put differently, say the user has selected suppliers X,Y,Z so what I need my Pivot to do is to show X,Y,Z suppliers but exclude A,B,C suppliers.
Here's the code I was able to find on a different webpage, but it didnt seem to work. I am using excel 2016. The other users said it worked for them but doesnt seem to work for me. The message I get is" Unable to get the PivotFields property of the PivotTable class"
Is there any way you guys can help me out?
Cheers
Dim pt As PivotTable, pi As PivotItem
Set pt = PIVOTALLKPI.PivotTables("PivotTable2")
Dim i As Long
With Me
For Each pi In pt.PivotFields("Supplier").PivotItems
pi.Visible = Not (wksData.Columns("E").Find(what:=pi.Name, lookat:=xlWhole, LookIn:=xlValues) Is Nothing)
Next
End With
I'm a newbie to VBA and decided to undertake a task to automate a report regarding supplier evaluation.
I have managed to automate all the actions needed to provide input data to my final excel sheet, created UserForm and ListBox and got to the point where my code copies selected items from listbox and pastes it to a new column
Anybody using my code, can select anywhere from 1-20 suppliers (that is 1-20 items from the listbox). Depending on their selection, I need my code to take the selection user made and filter my PivotTable based on that.
Put differently, say the user has selected suppliers X,Y,Z so what I need my Pivot to do is to show X,Y,Z suppliers but exclude A,B,C suppliers.
Here's the code I was able to find on a different webpage, but it didnt seem to work. I am using excel 2016. The other users said it worked for them but doesnt seem to work for me. The message I get is" Unable to get the PivotFields property of the PivotTable class"
Is there any way you guys can help me out?
Cheers
Dim pt As PivotTable, pi As PivotItem
Set pt = PIVOTALLKPI.PivotTables("PivotTable2")
Dim i As Long
With Me
For Each pi In pt.PivotFields("Supplier").PivotItems
pi.Visible = Not (wksData.Columns("E").Find(what:=pi.Name, lookat:=xlWhole, LookIn:=xlValues) Is Nothing)
Next
End With