VBA Pivot Table showing several PivotItems in PivotField, big data

bezwlosy

New Member
Joined
Aug 22, 2014
Messages
14
Hello everyone, it's my first post here.

This is Excel 2007.
I'm operating on a quite big database in Excel, 250 k rows. From these data, with VBA I create a pivot table.
Then I am trying to show only several items from one column, for example the column is "Country". Then I have a lot of different countries (items) there, maybe around 100-150.

I don't have a problem if I try show only one item, then I'm using:
Code:
pvt.PivotFields("op_kr_wys").PivotFilters.Add Type:=xlCaptionContains, Value1:="China"

But the problem appears when there is a need to show more than one, because then the loop is needed. And it takes a very long time to proceed, It seems like thinking and thinking, 10 minutes is not enough. When I stop and debug, the yellow line is "End If".

The code I'm using to select the chosen countries:
Code:
For Each pivotIt In pvt.PivotFields("op_kr_wys").PivotItems
    If pivotIt.Name <> "Chiny" And pivotIt.Name <> "Rosja" Then
    pivotIt.Visible = False
    End If
 Next pivotIt

As advised, I was also trying this, but didn't help:
Code:
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

Is there any way to make it faster? I will really appreciate any help. Thank you very much. Best regards.
PS: I'm a beginner.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,221,417
Messages
6,159,789
Members
451,589
Latest member
Harold14

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