+ Reply to Thread
Results 1 to 10 of 10

Formula to search and return cell based on criteria not working

  1. #1
    Registered User
    Join Date
    03-01-2012
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Formula to search and return cell based on criteria not working

    Hi all,

    I'm trying to make a formula that says "if cell A contains cell B AND does not contain cells C D or E, then cell A, else 1". My first effort only had one extra criteria:

    =IF((ISERROR(SEARCH(F$1,'Com. Development FN'!$M8))=TRUE)+(ISERROR(SEARCH(F$694,'Com. Development FN'!$M8))=FALSE),1,'Com. Development FN'!$M8)

    And it works like a charm. When I attempted to expand my criteria however (i.e. "does not contain cells C D or E", as opposed to "does not contain cell C"), all of it sudden it fails to work probably and always returns a value of "1":

    =IF((ISERROR(SEARCH(F$1,'Com. Development FN'!$M2))=TRUE)+(ISERROR(SEARCH(F$694,'Com. Development FN'!$M2))=FALSE)+(ISERROR(SEARCH(F$695,'Com. Development FN'!$M2))=FALSE)+(ISERROR(SEARCH(F$696,'Com. Development FN'!$M2))=FALSE),1,'Com. Development FN'!$M2)

    Anyone have any ideas what the issue here might be? I'm afraid I can't attach the spreadssheet itself as it contains confidential info, but I could potentially take screenshots of certain bits if that would help. Thanks very much for taking the time read!

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Formula to search and return cell based on criteria not working

    Try:

    =IF(AND(ISNUMBER(SEARCH(F$1,'Com. Development FN'!$M2)),SUMPRODUCT(--ISNUMBER(MATCH("*"&Sheet3!F$694:F$696&"*",'Com. Development FN'!$M2,0)))=0),'Com. Development FN'!$M2,1)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Formula to search and return cell based on criteria not working

    Think you'll find that should be

    =IF((ISERROR(SEARCH(F$1,'Com. Development FN'!$M2))=TRUE)*((ISERROR(SEARCH(F$694,'Com. Development FN'!$M2))=FALSE)+(ISERROR(SEARCH(F$695,'Com. Development FN'!$M2))=FALSE)+(ISERROR(SEARCH(F$696,'Com. Development FN'!$M2))=FALSE),1,'Com. Development FN'!$M2))

    * is usually related to AND
    + is usually related to OR
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Registered User
    Join Date
    03-01-2012
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Formula to search and return cell based on criteria not working

    Thanks very much for the replies guys; unfortunately NBVC's formula has a similar problem to my original one, and Special-K's has an error in it somewhere (not sure why changing the + to a * would result in an error though - weird).

    I'm going to keep trying and if I come with a solution I'll post it here.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Formula to search and return cell based on criteria not working

    FYI.

    My formula returns the value in M2 if the value in M2 contains whatever is in F1 and at the same time it does not contain what is in Sheet3!F$694, nor does it contain what is in Sheet3!F$695 nor what is contained in Sheet3!F$696.

    so if any of those from Sheet3!F$694:F$696 are contained in M2, then it will return 1.

  6. #6
    Registered User
    Join Date
    03-01-2012
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Formula to search and return cell based on criteria not working

    NVBC's formula does work, I was just applying it wrong!

    Thanks NVBC - saved me a ton of time that would otherwise have been spent manually searching through thousands of rows of data :D

  7. #7
    Registered User
    Join Date
    03-01-2012
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Formula to search and return cell based on criteria not working

    Sorry to drag up an old topic, but can anyone explain what this part of NVBC's formula means:

    MATCH("*"&Sheet3!F$694:F$696&"*"

    I understand that the ampersands are concatenation orders, but why are they necessary? And why are they concatenating the " "*" "? Why an asterisk? Why in quotation marks?

    Also, what exactly does the ":" mean? Is the formula matching that string of cells, or one cell after the other? Is it, in essence, performing multiple matches one after the other?

    Thanks!

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Formula to search and return cell based on criteria not working

    The asterisks are wildcards. We are looking for any of the text strings that are in the cells from f694 to f696 and trying find them anywhere in M2. We are concatenating wildcards to the front and back of each cell in f694:f696. The asterisks are greater like text and therefore are enclosed in quotes.

  9. #9
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Formula to search and return cell based on criteria not working

    Please mark this thread as solved.

  10. #10
    Registered User
    Join Date
    03-01-2012
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Formula to search and return cell based on criteria not working

    Awesome thanks! I understand now

+ 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