VBA Pivot Table Module not working

zgoda

New Member
Joined
Feb 10, 2016
Messages
14
Hello.
I want to make the following part of the code to work, but where it is, it isnt activating the filters:

Code:
Sheets("Clientes").Select
With ActiveSheet.PivotTables("Tabela dinâmica15").PivotFields("Regional")
.PivotItems("REG. SUL - LUCIANO").Visible = True
End With
ActiveSheet.PivotTables("Tabela dinâmica15").PivotFields("GA").ClearAllFilters

It works when i insert between the "End If" and the"Next Ws" in the following code, but in this case it runs one time for each worksheet and i have about 20 ws in this file and it takes about 10 minutes until im able to use my file.

Here is how I wanted executing the filter only once: (this doesnt work)

Code:
Case "REG. SUL"
Feuilles = Array("Venda Programada", "Venda Saldos", "Entrada Diária", "Pilares Comerciais", "Redimensionamentos", "Clientes", "Filtros Aba ClientesGR", "Consulta por Grupo")
On Error Resume Next
Sheets("Clientes").Select
With ActiveSheet.PivotTables("Tabela dinâmica15").PivotFields("Regional")
.PivotItems("REG. SUL - LUCIANO").Visible = True
End With
ActiveSheet.PivotTables("Tabela dinâmica15").PivotFields("GA").ClearAllFilters
For Each Ws In ThisWorkbook.Worksheets
Pos = Application.Match(Ws.Name, Feuilles, 0)
If Pos <> 0 Then
Ws.Visible = True
Pos = 0
Else
Ws.Visible = xlSheetVeryHidden
Pos = 0
End If

Next Ws
And here the working code, but taking too long, aplying once for each ws verification:

Code:
Case "REG. SUL"
Feuilles = Array("Venda Programada", "Venda Saldos", "Entrada Diária", "Pilares Comerciais", "Redimensionamentos", "Clientes", "Filtros Aba ClientesGR", "Consulta por Grupo")
On Error Resume Next
For Each Ws In ThisWorkbook.Worksheets
Pos = Application.Match(Ws.Name, Feuilles, 0)
If Pos <> 0 Then
Ws.Visible = True
Pos = 0
Else
Ws.Visible = xlSheetVeryHidden
Pos = 0
End If

Sheets("Clientes").Select
With ActiveSheet.PivotTables("Tabela dinâmica15").PivotFields("Regional")
.PivotItems("REG. SUL - LUCIANO").Visible = True
End With
ActiveSheet.PivotTables("Tabela dinâmica15").PivotFields("GA").ClearAllFilters

Next Ws

Can you guys help me?
And if there was a way to make this filter work in all pivot tables in the file, would be even better. this is for only one pivot table in specific.
Example
Login: REG. SUL
password: 1111

Thanks!
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
If there is any info that i could provide to you guys to help me with my problem im available to explain it.

Sorry for the bump.
 
Upvote 0
I've found a way to make it work faster.

I had just to make the Calculation options be Manual.

Thanks guys.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top