+ Reply to Thread
Results 1 to 6 of 6

If statement help

  1. #1
    Registered User
    Join Date
    07-28-2005
    Posts
    37

    If statement help

    I have a worksheet, and if cell 1 contains the word "Minimum," I need it to compare cells 2 and 3. I need it to run the equation in cell 4
    =if(cell3>=cell2,"yes","no")
    But if cell1 contains the word Maximum, I need it to compare cells 2 and 3 and run the equation:
    =if(cell3<=cell2,"Yes","No")
    I think you can use the =find statement, but I cannot get it to work. Any suggestions?

  2. #2
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    I see two options...

    1) the cell (e.g. A1) must contain either MINIMUM or MAXIMUM (no blanks or other values) use this formula:

    =IF(A1="MINIMUM",IF(C1>=B1,"YES","NO"),IF(C1<=B1,"YES","NO")) --or this formula:
    =IF(OR(AND(A1="MINIMUM",C1>=B1),AND(A1="MAXIMUM",C1<=B1)),"yes","no")

    2) the cell (e.g. A1) may be blank or contain something other than Min. or Max.

    =IF(A1="MINIMUM",IF(C1>=B1,"YES","NO"),IF(A1="MAXIMUM",IF(C1<=B1,"YES","NO"),"N/A")) --or this formula:
    =IF(OR(AND(A1="minimum",C1>=B1),AND(A1="maximum",C1<=B1)),"yes",IF(OR(A1="MINIMUM",A1="MAXIMUM"),"NO","N/A"))

    Is this what you were looking for?

    Bruce
    Bruce
    The older I get, the better I used to be.
    USA

  3. #3
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    One other option I just realized, is that the words MINIMUM or MAXIMUM may be contained within other text (e.g. "Value is MINIMUM")....

    =IF(NOT(ISERROR(FIND("MINIMUM",A1)>0)),IF(C1>=B1,"YES","NO"),IF(NOT(ISERROR(FIND("MAXIMUM",A1)>0)),IF(C1<=B1,"YES","NO"),"N/A"))

    note that the FIND function IS case sensitive. MINIMUM, minimum and Minimum are all different and, in my example, only MINIMUM will return the desired answer. The others will return "N/A".

    this can be overcome by using SEARCH instead of FIND, as such:

    =IF(NOT(ISERROR(SEARCH("MINIMUM",A1)>0)),IF(C1>=B1,"YES","NO"),IF(NOT(ISERROR(SEARCH("MAXIMUM",A1)>0)),IF(C1<=B1,"YES","NO"),"N/A"))


    HTH

    Bruce

  4. #4
    JE McGimpsey
    Guest

    Re: If statement help

    One way:


    =IF(A1="Minimum",IF(A3>=A2,"Yes","No"), IF(A1="Maximum",
    IF(A3<=A2,"Yes","No"),""))

    In article <[email protected]>,
    mkerstei <[email protected]>
    wrote:

    > I have a worksheet, and if cell 1 contains the word "Minimum," I need it
    > to compare cells 2 and 3. I need it to run the equation in cell 4
    > =if(cell3>=cell2,"yes","no")
    > But if cell1 contains the word Maximum, I need it to compare cells 2
    > and 3 and run the equation:
    > =if(cell3<=cell2,"Yes","No")
    > I think you can use the =find statement, but I cannot get it to work.
    > Any suggestions?


  5. #5
    Bernie Deitrick
    Guest

    Re: If statement help

    Enter this in Cell 4, replacing the Cell1, Cell2, and Cell3 with the addresses of the appropriate
    cells:

    =IF(NOT(ISERROR(FIND("minimum",LOWER(Cell1)))),IF(Cell3>=Cell2,"yes","no"),IF(NOT(ISERROR(FIND("maximum",LOWER(Cell1)))),IF(Cell3<=Cell2,"yes","no"),"Neither"))

    HTH,
    Bernie
    MS Excel MVP


    "mkerstei" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I have a worksheet, and if cell 1 contains the word "Minimum," I need it
    > to compare cells 2 and 3. I need it to run the equation in cell 4
    > =if(cell3>=cell2,"yes","no")
    > But if cell1 contains the word Maximum, I need it to compare cells 2
    > and 3 and run the equation:
    > =if(cell3<=cell2,"Yes","No")
    > I think you can use the =find statement, but I cannot get it to work.
    > Any suggestions?
    >
    >
    > --
    > mkerstei
    > ------------------------------------------------------------------------
    > mkerstei's Profile: http://www.excelforum.com/member.php...o&userid=25688
    > View this thread: http://www.excelforum.com/showthread...hreadid=392939
    >




  6. #6
    Registered User
    Join Date
    07-28-2005
    Posts
    37
    Thank you! This solved my problem.

+ 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