I created a combobox with a list of customers. From the value selected, which is transfered to another cell automatically, I want to filter my PivotTable.
I recorded a macro to help me start but i'm completely lost.
Can anyone help?
Here is the macro I created
Sub Macro2()
'
' Macro2 Macro
'
'
With ActiveSheet.PivotTables("teste").PivotFields("Customer")
.PivotItems("ALFKI").Visible = False
.PivotItems("ANTON").Visible = False
.PivotItems("AROUT").Visible = False
.PivotItems("BERGS").Visible = False
.PivotItems("BLAUS").Visible = False
.PivotItems("BLONP").Visible = False
.PivotItems("BOLID").Visible = False
.PivotItems("BONAP").Visible = False
.PivotItems("BOTTM").Visible = False
.PivotItems("BSBEV").Visible = False
.PivotItems("CACTU").Visible = False
.PivotItems("CHOPS").Visible = False
.PivotItems("COMMI").Visible = False
.PivotItems("CONSH").Visible = False
.PivotItems("DRACD").Visible = False
.PivotItems("DUMON").Visible = False
.PivotItems("EASTC").Visible = False
.PivotItems("ERNSH").Visible = False
.PivotItems("FAMIA").Visible = False
.PivotItems("FOLIG").Visible = False
.PivotItems("FOLKO").Visible = False
.PivotItems("FRANK").Visible = False
.PivotItems("FRANR").Visible = False
.PivotItems("FRANS").Visible = False
.PivotItems("FURIB").Visible = False
.PivotItems("GALED").Visible = False
.PivotItems("GODOS").Visible = False
.PivotItems("GOURL").Visible = False
.PivotItems("GREAL").Visible = False
.PivotItems("GROSR").Visible = False
.PivotItems("HANAR").Visible = False
.PivotItems("HILAA").Visible = False
.PivotItems("HUNGC").Visible = False
.PivotItems("HUNGO").Visible = False
.PivotItems("ISLAT").Visible = False
.PivotItems("KOENE").Visible = False
.PivotItems("LAMAI").Visible = False
.PivotItems("LAUGB").Visible = False
.PivotItems("LAZYK").Visible = False
.PivotItems("LEHMS").Visible = False
.PivotItems("LETSS").Visible = False
.PivotItems("LILAS").Visible = False
.PivotItems("LINOD").Visible = False
.PivotItems("LONEP").Visible = False
.PivotItems("MAGAA").Visible = False
.PivotItems("MAISD").Visible = False
.PivotItems("MEREP").Visible = False
End With
With ActiveSheet.PivotTables("teste").PivotFields("Customer")
.PivotItems("MORGK").Visible = False
.PivotItems("NORTS").Visible = False
.PivotItems("OCEAN").Visible = False
.PivotItems("OLDWO").Visible = False
.PivotItems("OTTIK").Visible = False
.PivotItems("PERIC").Visible = False
.PivotItems("PICCO").Visible = False
.PivotItems("PRINI").Visible = False
.PivotItems("QUEDE").Visible = False
.PivotItems("QUEEN").Visible = False
.PivotItems("QUICK").Visible = False
.PivotItems("RANCH").Visible = False
.PivotItems("RATTC").Visible = False
.PivotItems("REGGC").Visible = False
.PivotItems("RICAR").Visible = False
.PivotItems("RICSU").Visible = False
.PivotItems("SANTG").Visible = False
.PivotItems("SAVEA").Visible = False
.PivotItems("SEVES").Visible = False
.PivotItems("SIMOB").Visible = False
.PivotItems("SPECD").Visible = False
.PivotItems("SPLIR").Visible = False
.PivotItems("SUPRD").Visible = False
.PivotItems("THEBI").Visible = False
.PivotItems("THECR").Visible = False
.PivotItems("TOMSP").Visible = False
.PivotItems("TORTU").Visible = False
.PivotItems("TRADH").Visible = False
.PivotItems("TRAIH").Visible = False
.PivotItems("VAFFE").Visible = False
.PivotItems("VICTE").Visible = False
.PivotItems("VINET").Visible = False
.PivotItems("WANDK").Visible = False
.PivotItems("WARTH").Visible = False
.PivotItems("WELLI").Visible = False
.PivotItems("WHITC").Visible = False
.PivotItems("WILMK").Visible = False
.PivotItems("WOLZA").Visible = False
End With
End Sub
I recorded a macro to help me start but i'm completely lost.
Can anyone help?
Here is the macro I created
Sub Macro2()
'
' Macro2 Macro
'
'
With ActiveSheet.PivotTables("teste").PivotFields("Customer")
.PivotItems("ALFKI").Visible = False
.PivotItems("ANTON").Visible = False
.PivotItems("AROUT").Visible = False
.PivotItems("BERGS").Visible = False
.PivotItems("BLAUS").Visible = False
.PivotItems("BLONP").Visible = False
.PivotItems("BOLID").Visible = False
.PivotItems("BONAP").Visible = False
.PivotItems("BOTTM").Visible = False
.PivotItems("BSBEV").Visible = False
.PivotItems("CACTU").Visible = False
.PivotItems("CHOPS").Visible = False
.PivotItems("COMMI").Visible = False
.PivotItems("CONSH").Visible = False
.PivotItems("DRACD").Visible = False
.PivotItems("DUMON").Visible = False
.PivotItems("EASTC").Visible = False
.PivotItems("ERNSH").Visible = False
.PivotItems("FAMIA").Visible = False
.PivotItems("FOLIG").Visible = False
.PivotItems("FOLKO").Visible = False
.PivotItems("FRANK").Visible = False
.PivotItems("FRANR").Visible = False
.PivotItems("FRANS").Visible = False
.PivotItems("FURIB").Visible = False
.PivotItems("GALED").Visible = False
.PivotItems("GODOS").Visible = False
.PivotItems("GOURL").Visible = False
.PivotItems("GREAL").Visible = False
.PivotItems("GROSR").Visible = False
.PivotItems("HANAR").Visible = False
.PivotItems("HILAA").Visible = False
.PivotItems("HUNGC").Visible = False
.PivotItems("HUNGO").Visible = False
.PivotItems("ISLAT").Visible = False
.PivotItems("KOENE").Visible = False
.PivotItems("LAMAI").Visible = False
.PivotItems("LAUGB").Visible = False
.PivotItems("LAZYK").Visible = False
.PivotItems("LEHMS").Visible = False
.PivotItems("LETSS").Visible = False
.PivotItems("LILAS").Visible = False
.PivotItems("LINOD").Visible = False
.PivotItems("LONEP").Visible = False
.PivotItems("MAGAA").Visible = False
.PivotItems("MAISD").Visible = False
.PivotItems("MEREP").Visible = False
End With
With ActiveSheet.PivotTables("teste").PivotFields("Customer")
.PivotItems("MORGK").Visible = False
.PivotItems("NORTS").Visible = False
.PivotItems("OCEAN").Visible = False
.PivotItems("OLDWO").Visible = False
.PivotItems("OTTIK").Visible = False
.PivotItems("PERIC").Visible = False
.PivotItems("PICCO").Visible = False
.PivotItems("PRINI").Visible = False
.PivotItems("QUEDE").Visible = False
.PivotItems("QUEEN").Visible = False
.PivotItems("QUICK").Visible = False
.PivotItems("RANCH").Visible = False
.PivotItems("RATTC").Visible = False
.PivotItems("REGGC").Visible = False
.PivotItems("RICAR").Visible = False
.PivotItems("RICSU").Visible = False
.PivotItems("SANTG").Visible = False
.PivotItems("SAVEA").Visible = False
.PivotItems("SEVES").Visible = False
.PivotItems("SIMOB").Visible = False
.PivotItems("SPECD").Visible = False
.PivotItems("SPLIR").Visible = False
.PivotItems("SUPRD").Visible = False
.PivotItems("THEBI").Visible = False
.PivotItems("THECR").Visible = False
.PivotItems("TOMSP").Visible = False
.PivotItems("TORTU").Visible = False
.PivotItems("TRADH").Visible = False
.PivotItems("TRAIH").Visible = False
.PivotItems("VAFFE").Visible = False
.PivotItems("VICTE").Visible = False
.PivotItems("VINET").Visible = False
.PivotItems("WANDK").Visible = False
.PivotItems("WARTH").Visible = False
.PivotItems("WELLI").Visible = False
.PivotItems("WHITC").Visible = False
.PivotItems("WILMK").Visible = False
.PivotItems("WOLZA").Visible = False
End With
End Sub