+ Reply to Thread
Results 1 to 7 of 7

Using a NOT modifier within Search()

  1. #1
    Forum Contributor
    Join Date
    06-18-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2013
    Posts
    118

    Question Using a NOT modifier within Search()

    Hello

    I have the following formula in place:
    Please Login or Register  to view this content.
    Basically It searches Sheet1 A:A for all occurrences of a text string (B620&"-"&C620) plus the string "SP" and gives me the sum of corresponding values in sheet1 B:B. This function works for what I need, but now in another spot I need to do the opposite and find all instances with (B620&"-"&C620) that does NOT contain "SP". I also need to NOT contain a few other strings, ie. {"SP", "XS","S","L","XL"} and maybe a few others.

    So, If I have the following (B620 is "BR5", C620 is "45WH") and the Do Not Find list is as described above then:
    BR5-45WH-XL (SP1)............15
    BR5-45WH-5XLL..................20
    BR5-45WH-S.......................13
    BR5-45WH-8XL....................17
    BR6-49RB-5XLL...................22

    I would want the result 37 (20+17). I was thinking that maybe using <> would work like SEARCH(B620&"-"&C620&<>{"SP", "XS","S","L","XL"} , Sheet1....etc), but that doesn't seem to work.

    Thanks
    Last edited by weeble33; 06-26-2012 at 12:37 PM. Reason: Title Change

  2. #2
    Forum Contributor
    Join Date
    06-18-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2013
    Posts
    118

    Re: Searching for everything but...

    I'm not so sure that my title, "Searching for everything but..." didn't describe my problem, but ok.

  3. #3
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Using a NOT modifier within Search()

    i played around with a very small range of test data, and here is the formula for that:

    Please Login or Register  to view this content.
    the portion of interest for you is highlighted.

    you asked for the ability to designate a bunch of values in the NOT section, which i am not able to achieve at the moment. this post will help bump up the thread and, i hope, a 'guru' will help you out; else, i will be attempting to do it anyway, and i will get you an answer (sooner or later :D)...

    by the way, there is a downside to using SEARCH along with a string like "XL" in your attempt at exclusion; it will exclude XL, XLL, 5XLL, 8XL etc...
    Last edited by icestationzbra; 06-20-2012 at 08:32 PM. Reason: add'l info
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  4. #4
    Forum Contributor
    Join Date
    06-18-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2013
    Posts
    118

    Re: Using a NOT modifier within Search()

    Thank you for the reply, icestationzbra.

    On one of my sheets, I have come to the same conclusion as you have. And I have also realized the fallibility of search() in exactly the examples you've shown. My data is organized in a way so that I can reduce some of those factors by preceding them with a dash:
    Please Login or Register  to view this content.
    This helps identify between al least "xl" and "5xl", but I still have the problem of "xll" being a valid term as you've pointed out. I've thought about using a space in the parameters "-xl " to make sure that it doesn't include the second "L", but as my example set above shows, very few entries contain a space after the size is listed. Ultimately, my current formula, which is probably 90-95% accurate, is this eye sore:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Using a NOT modifier within Search()

    i attempted something, which, i hope, helps you a wee bit. again, the same problem with "like" strings exists here, too.

    i sincerely hope some 'guru' helps you out here, since i would also like to learn how to do this the right way.

  6. #6
    Forum Contributor
    Join Date
    06-18-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2013
    Posts
    118

    Re: Using a NOT modifier within Search()

    Yea, I triedd something like that once upon a time, but I can't get the multiple parameters to work out, which for yours seems to work for some but not others. Here's mine:
    Please Login or Register  to view this content.
    I removed "-xl" and "-5xl" from the list jsut to avoid the "like" strings. But for this I get an #N/A error and the weird part is that when doing a formula evaluation, the search parameters error out differently. The first 5 get #value errors and the last three get #N/A errors.

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Using a NOT modifier within Search()

    weeble33,

    I would use sumif instead of isnumber(search()):
    Please Login or Register  to view this content.
    The first sumif gets the total, the second sumif gets the total of items you want to exclude. So subtract the second from the first to get the desired result. Example attached.

    Note that similar items will still cause issues. So -XLL will get excluded because it is similar to -XL.
    Attached Files Attached Files
    Last edited by tigeravatar; 06-21-2012 at 02:16 PM. Reason: typo
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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