Filtering pivot table according to cell values (VBA)

hanmas

New Member
Joined
Feb 19, 2012
Messages
24
Hi guys,
I feel I am missing something glaringly obvious here, but how can I use VBA to automatically filter a pivot table based on text contained within values? For example, I would like use a macro to automatically filter the following dataset to contain only rows where Product *contains* either "IX", "MM" or "NX":

Product ValueA ValueB
VD:IX:L:MM: Text Text 623 187
VD:MM: Text Text 390 80
VD:IX: Text Text 1100 430
VD:NX: Text Text 1235 685
VD:SP:L:FV: Text Text 96 63
VD:KP:L:FV: Text Text 0 0

Note that in reality, the pivot has 20,000 rows and I will need to filter for maybe thirty different values within the product names...
Thanks very much for your help,
Graham
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
With a formatted table this time :)
HTML:
Product	                  ValueA  ValueB
VD:IX:L:MM: Text Text	    623	   187
VD:MM: Text Text	    390	    80
VD:IX: Text Text	   1100	   430
VD:NX: Text Text	   1235	   685
VD:SP:L:FV: Text Text	     96	    63
VD:KP:L:FV: Text Text	      0      0
 
Last edited:
Upvote 0
Anyone able to help with this one please? I'm really struggling here...there must be a way to automatically filter a pivot table according to a defined set of text values by matching text within strings rather than matching the full string?
Thanks in advance for your help,
Graham
 
Upvote 0
Hi,

Perhaps add a column alongside your dataset with the formula:

=SUMPRODUCT(--ISNUMBER(SEARCH({"IX","MM","NX"},A2)))>0

Add this column to your PivotTable and filter for TRUE.
 
Upvote 0

Forum statistics

Threads
1,215,504
Messages
6,125,185
Members
449,213
Latest member
Kirbito

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