problem using VBA filter in Pivot tables

wassita

New Member
Joined
Mar 13, 2011
Messages
13
Hello!
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
I am using excel 2007 and I have problems to apply a filter to a pivotfield. I am trying the following:



<o:p></o:p>
<o:p></o:p>
ActiveSheet.PivotTables(1).PivotFields("Branch").PivotFilters.Add Type:=xlValueEquals, Value1:=2


<o:p></o:p>
<o:p></o:p>
It generates a run time error '1004' saying it is not possible to get the property pivottables from class worksheet.

<o:p></o:p>
<o:p></o:p>
My real goal is to use an array to specify more than one value to be used in the filter. It would be something like this:



<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
ActiveSheet.PivotTables(1).PivotFields("Branch").PivotFilters.Add Type:=xlValueEquals, Value1:= array(2,4,15,9)

<o:p></o:p>
<o:p></o:p>
I really thank any help I get to solve this problem. <o:p></o:p>
 
Thank's a lot.

I want to set a filter in a pivot table.
I try to use PivotFilters from 8 days and any scripts works :

Dim Var_Filter_Ping_S3 As PivotField
Set Var_Filter_Ping_S3 = Feuil29.PivotTables(1).PivotFields("File")
Var_Filter_Ping_S3.ClearAllFilters
Var_Filter_Ping_S3.PivotFilters.Add xlValueEquals, , "A"

Your metod wors fine !!
Happy day :-)
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
Latest member
Dupuhini

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