+ Reply to Thread
Results 1 to 5 of 5

Nested IF statements

  1. #1
    Registered User
    Join Date
    04-13-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Nested IF statements

    I have three different IF statements (below) in my spreadsheet and I'd like to "merge" these into one big IF statement (i.e., put all three of these in one cell). What would be the syntax?

    =IF(AND(C2=$O$1,(F2*$O$9)>G2),(F2*$O$4)*$M$16,G2*$M$16)

    =IF(AND(B2=$O$1,(G2/$O$16)>F2),(G2/$O$3)*$M$16,F2*$M$16)

    =IF(AND(B2<>$O$1,C2<>$O$1,(F2/$O$23)>(G2*$O$9)),(F2/$O$6)*$M$16,(G2*$O$4)*$M$16)


    Thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Nested IF statements

    Is it posible to upload a sample workbook?
    Sincerely
    S?ren Larsen

    "Give a man a fish, and you'll feed him for a day. Give a man a fishing rod, and he'll steal your yacht!"

  3. #3
    Registered User
    Join Date
    04-13-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Nested IF statements

    Column H in the attached (labeled "Calculation") is where the multiple IF statements need to go. The first three rows (shaded red) contain IF statement #1 that I pasted in my original post above. The second three rows (green) have the second IF statement. The final three rows (blue) have the third IF statement. The goal is to get all three of these IF statements into one cell.

    The idea here is that I do a different calculation based on whether Value1 is 'Cat', Value2 is 'Cat', or if neither one of them is 'Cat'.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Nested IF statements

    In H2:

    =IF(C2=$O$1,IF(AND(C2=$O$1,(F2*$O$9)>G2),(F2*$O$4)*$M$16,G2*$M$16),IF(B2=$O$1,IF(AND(B2=$O$1,(G2/$O$16)>F2),(G2/$O$3)*$M$16,F2*$M$16),IF(AND(B2<>$O$1,C2<>$O$1,(F2/$O$23)>(G2*$O$9)),(F2/$O$6)*$M$16,(G2*$O$4)*$M$16)))

    And copy down. Perhaps some elements of the formula are redundant now, but it should work.

  5. #5
    Registered User
    Join Date
    04-13-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Nested IF statements

    Thank you, that worked. This is how I tried it originally. This did NOT work:

    =IF(AND(C2=$O$1,(F2*$O$9)>G2),(F2*$O$4)*$M$16,G2*$M$16),IF(AND(B2=$O$1,(G2/$O$16)>F2),(G2/$O$3)*$M$16,F2*$M$16),IF(AND(B2<>$O$1,C2<>$O$1,(F2/$O$23)>(G2*$O$9)),(F2/$O$6)*$M$16,(G2*$O$4)*$M$16)))

    Here is your version, which did work, and highlighting the parts that were missing from mine:

    =IF(C2=$O$1,IF(AND(C2=$O$1,(F2*$O$9)>G2),(F2*$O$4)*$M$16,G2*$M$16),IF(B2=$O$1,IF(AND(B2=$O$1,(G2/$O$16)>F2),(G2/$O$3)*$M$16,F2*$M$16),IF(AND(B2<>$O$1,C2<>$O$1,(F2/$O$23)>(G2*$O$9)),(F2/$O$6)*$M$16,(G2*$O$4)*$M$16)))

+ 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