+ Reply to Thread
Results 1 to 14 of 14

Check If Value Exists in PivotTable (as a PivotItem)

  1. #1
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Check If Value Exists in PivotTable (as a PivotItem)

    Hello,

    I have a PivotTable full of Customer data. When I select a Customer in the Report Filter/PageField, it shows me a list of products purchased.

    How do I check the entire range of products purchased by that customer for a specific product? If the range does not contain that product name, it would show me a MsgBox saying "No.".
    Last edited by EnigmaMatter; 03-09-2014 at 12:34 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    Why don't you use the raw data rather than the pivot table?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    There is too much raw data to sort through, and it is a very messy export from an accounting program.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    You could use a formula.

  5. #5
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    Norie,

    I appreciate that, but I really don't think that methodology will work with the rest of the application.

    I can't post the application (and an example workbook would be wonky). Is there not a way to check a range for a value and then return a message if the value exists in the range (anywhere)?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    Yes, you could find out if a value exists in a range by using a formula like MATCH which could be implemented in code via Application.Match.

  7. #7
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    Norie,

    I will give that a shot.

  8. #8
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    Norie,

    The MATCH formula returns a value that tells me the position of the lookup_value in the lookup_array. However, if the lookuo_value doesn't exist, it simply tells me how many values are in the array.ell

    I had an idea to use a COUNTA formula to tell me how many values are in the array, and if the MATCH and COUNTA values were the same, then I'd know there is no match. However, this won't work if the lookup_value is the last value in the array -- I wouldn't know if there wasn't a match or not. Is there a boolean version of the MATCH formula that returns TRUE/FALSE?

  9. #9
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check If Value Exists in PivotTable (as a PivotItem)

    I used the Match_Type (didn't see that...).

    I will now try to make something that works and will let you know what I come up with.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Check If Value Exists in PivotTable (as a PivotItem)

    Match doesn't return the no of values in the array if the value you are looking for doesn't exist, it returns an error.

  11. #11
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check 'f Value Exists in PivotTable (as a PivotItem)

    Norie,

    I will try to implement the following into my application:
    Please Login or Register  to view this content.
    If it works, I will mark thread as solved.

  12. #12
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check If Value Exists in PivotTable (as a PivotItem)

    You're right, but only if you do not omit the match-type.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Check If Value Exists in PivotTable (as a PivotItem)

    If you omit the match type it defaults to 1 and Match finds the largest value less than or equal to the value being looked for.

  14. #14
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Check If Value Exists in PivotTable (as a PivotItem)

    Thank you; I appreciate it.

+ 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. [SOLVED] Pivottable - cycle through each PivotItem
    By rasonline in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2014, 05:22 AM
  2. Replies: 0
    Last Post: 06-14-2013, 12:33 PM
  3. [SOLVED] PivotItems in a PivotTable position -- Skip if PivotItem errors
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-28-2013, 10:03 AM
  4. test if a Report Filter exists in a Pivottable
    By djblois1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-07-2012, 09:57 AM
  5. PivotTable field name already exists.
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2010, 11:11 AM

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