+ Reply to Thread
Results 1 to 5 of 5

IF AND Formula

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    IF AND Formula

    I am trying to use an IF AND formula

    This is want I want to do:

    If (G2-F2) is <0 and if (H2) is also <0, I want it to output a 1

    and

    If (G2-F2) is >0 and if (H2) is also >0, I want it to output a 1

    else, I want it to output a 0.

    How can I write this into a formula?

    Thanks!

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF AND Formula

    Try

    =--OR(AND(G2-F2<0,H2<0),AND(G2-F2>0,H2>0))

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: IF AND Formula

    =if(and(g2-f2<0,h2<0),1,if(and(g2-h2>0,h2>0),1,0)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF AND Formula

    Here's another way, but it's making an assumption..

    You specified >0 and <0.
    but didn't say anything about exactly 0

    If both (H2 and G2-F2) are 0, should it still be a 1 ?
    If so, then you can use
    =--(SIGN(H2)=SIGN(G2-F2))

  5. #5
    Registered User
    Join Date
    09-10-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: IF AND Formula

    Thanks for the prompt response, it worked great

    Quote Originally Posted by martindwilson View Post
    =if(and(g2-f2<0,h2<0),1,if(and(g2-h2>0,h2>0),1,0)

+ 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