+ Reply to Thread
Results 1 to 10 of 10

Pivot with Filter by Multiple Contains?

  1. #1
    Forum Contributor
    Join Date
    10-27-2005
    Posts
    177

    Pivot with Filter by Multiple Contains?

    Aaack this is driving me crazy! Is there any way to do a pivot filter with multiple contains?

    Say I want to filter pivot field "Type" to make visible the pivot item if it contains the word "type1" OR "type2" . Is there a code that can achieve this?

    I normally use this code to filter by specific pivot items:

    Please Login or Register  to view this content.
    But this only works if I the pivot item is exactly type1 or type2. But if a pivot item like "bla bla type1" exists and I want that visible, I'd have to list that in the above code as well. So contains is a more appropriate filter but I am having a really hard time finding a code that allows for multiple contains.

    Any help would be very much appreciated.



    Edit: I have attached a file with data and desired result.
    Attached Files Attached Files
    Last edited by uberathlete; 06-28-2014 at 11:45 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Pivot with Filter by Multiple Contains?

    Hi,

    Do you really need a macro to manipulate a pivot table? Why can't you just use the normal filtering options?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    10-27-2005
    Posts
    177

    Re: Pivot with Filter by Multiple Contains?

    Afraid not because there can be hundreds of pivot items that contain the words "type1" and "type2", and well ... my boss asked for it, lol. So I'm in quite a bind.

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Pivot with Filter by Multiple Contains?

    show a small excel example and the desired result.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  5. #5
    Forum Contributor
    Join Date
    10-27-2005
    Posts
    177

    Re: Pivot with Filter by Multiple Contains?

    Hi oeldere. I have attached a file in my opening post.

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Pivot with Filter by Multiple Contains?

    Please Login or Register  to view this content.
    basicly you have another question.

    how you extract text out of a cell. e.g. type1.

    If you are able to achieve that, you can use that formula in column C (helpcolumn) and use that column in the pivot table.

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Pivot with Filter by Multiple Contains?

    This looks like an "Instr()" type of VBA function is needed...

    If INSTR(ucase(cells(4,"A")),"TYPE1") >0 then ' this will test to see if "type1" is contained in the cell A4.

    I hope you can expand on this to make your code work for you.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  8. #8
    Forum Contributor
    Join Date
    10-27-2005
    Posts
    177

    Re: Pivot with Filter by Multiple Contains?

    Hmm I think I got it. This is the code I used for those intrested:

    Please Login or Register  to view this content.
    Last edited by uberathlete; 06-28-2014 at 01:20 PM.

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Pivot with Filter by Multiple Contains?

    Good Job!!

    Looks like you got it!! I'm a little worried about "Type1" vs "type1" vs "TYPE1" not being the same. That is why I did an UCase in my example.

  10. #10
    Forum Contributor
    Join Date
    10-27-2005
    Posts
    177

    Re: Pivot with Filter by Multiple Contains?

    Thanks MarvinP. Your suggestion made all the difference. With regards to case sensitivity, I believe vbtextcompare ignores case, so it would treat Type1, type1, and TYPE1 as the same.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. One filter/ Master filter multiple pivot tables based on worksheet...
    By jlworden in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 04-10-2013, 11:16 AM
  2. [SOLVED] One filter/ Master filter for multiple pivot tables...
    By jlworden in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-09-2013, 04:35 PM
  3. Duplicate Report Filter and Row Labels Filter Across Multiple Pivot Tables
    By tash in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2013, 05:32 PM
  4. Change Pivot table Filter Based on Cell Value *Multiple Filter items* Possible?
    By Flydd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2012, 06:57 AM
  5. Replies: 3
    Last Post: 06-23-2009, 01:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1