+ Reply to Thread
Results 1 to 16 of 16

Problem with multiple IF statement

  1. #1
    Registered User
    Join Date
    08-15-2007
    Posts
    10

    Problem with multiple IF statement

    I am trying to write a formula that will do multiple IF statements checking to see if words are written in certian boxes and if so to do certian things and I need help, never done multiple IF statements in one formula before and can't find anything in the books I have or on the web that pertains to this so any help would be appreciated and thank you in advance.

    PROBLEM:

    = IF(D30 = "Oceanic",
    IF(D35 = "Yes",
    Both True
    (((D32 * 4) + (D33 * 5) + (D34 * 9) + D31) * 0.15) + ((D32 * 4) + (D33 * 5) + (D34 * 9) + (D31 + 4500)),

    Oceanic = "Oceanic", D35 = "No"
    (((D32 * 4) + (D33 * 5) + (D34 * 9) + D31) * 0.15) + ((D32 * 4) + (D33 * 5) + (D34 * 9) + D31)

    Oceanic = False, D35 = "Yes"
    ((d32 * 4) + (d33 * 5) + (d34 * 9) + (4500 + d31))

    Both False
    ((d32 * 4) + (d33 * 5) + (d34 * 9))

    =======================================================
    I got:

    = IF(D30 = "Oceanic", IF(D35 = "Yes", (((D32 * 4) + (D33 * 5) + (D34 * 9) + D31) * 0.15) + ((D32 * 4) + (D33 * 5) + (D34 * 9) + (D31 + 4500)), (((D32 * 4) + (D33 * 5) + (D34 * 9) + D31) * 0.15) + ((D32 * 4) + (D33 * 5) + (D34 * 9) + D31), ((d32 * 4) + (d33 * 5) + (d34 * 9) + (4500 + d31)), ((d32 * 4) + (d33 * 5) + (d34 * 9))

    But it says too many arguments so any help on this is appreciated.

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

    just make sure the math is right for all combinations....

    Please Login or Register  to view this content.
    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
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    =((D32*4)+(D33*5)+(D34*9)+D31)*0.15+(D32*4)+(D33*5)+(D34*9)+D31+IF(D30="Oceanic",IF(D35="yes",4500,0),(D32*4)+(D33*5)+(D34*9)+IF(D30=FALSE,IF(D35="Yes",4500+D31,0)))

    Ok here is the problem with that one, it will add up correctly but ONLY if D30 = "Oceanic", if not, the result is totally wrong, it will add up both the first lines and the If = True and almost double the correct expected results.

    I only use a 1 in D32 to test the results to make it easier:

    D30 = "Oceanic" & D35 = "Yes"
    Result: 4,504.6
    D30 = "Oceanic" & D35 = False
    Result: 4.6
    D30 = False & D35 = "Yes"
    Result: 8.6 But Correct Result should be: 4,504
    D30 = False & D35 = False
    Result: 8.6 But correct Result should be: 4

    So you see I am having problems trying to figure out the code for it since I am pretty new to Excel, I can do the basic things but multiple IF statements are beyond me. =(

    Thank you for the help anyway, it is appreciated. =)

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

    Please Login or Register  to view this content.

    If not, please tell me what numbers you put in D31, D32, D33 and D34 to get the results you submitted above.

  5. #5
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    =IF(D30="Oceanic",((D32*4)+(D33*5)+(D34*9)+D31)*0.15+(D32*4)+(D33*5)+(D34*9)+D31+IF(D35="yes",4500,0),IF(D30=FALSE,(D32*4)+(D33*5)+(D34*9)+IF(D35="Yes",4500+D31,0)))

    Nope, that's not it either, The Result comes out "False" instead of a calculation and narrowed it down to the IF(D30 = False, statement I believe.

    and I have no other information in any of the other boxes, just a 1(D32 = 1 * 4) in D32 to come up with those results.

    IF Oceaning AND IF "Yes" then (4 * .15) = 4.6 + 4,500 = 4,504.6
    IF Oceanic and IF(D35 = "No" then (4 * .15) + 4) = 4.6
    IF NOT Oceanic and IF = "Yes" then (4 + 4,500) = 4,504
    IF NOT Oceanic and IF(D35 = False"No" then Result = 4

    D32 = 1
    D33 = Blank
    D34 = Blank

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

    With the last formula I gave you and a 1 entered in D32, I get the results that you gave....


    Note: I actually put the word FALSE in the cells....did you you mean blanks?


    or maybe you meant "NO" instead of FALSE?

    perhaps?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by NBVC; 08-15-2007 at 02:29 PM.

  7. #7
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    Here is my file, D37 is where I am trying to put the formula in at.
    Attached Files Attached Files

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

    I think we got confused with the "No" and "False".... you meant "No" at all times, I thought you said you had a choice between "Yes", "No" & False....Also, I thought you had a choice of "Oceanic" or False...I didn't know you had a drop down list with multiple choices...

    Sometimes it is just better to see the actual sheet....

    At any rate...try this. I tested it on your sheet and it gives the desired results.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    THANK YOU!!!!

    Works great from what I see, gonna test it with other numbers and check results to verify it and sorry for the confusion with the Yes, No, and False, didn't think about it, was hard trying to explain it on a forum in my opition so you are right, better to look at it so you can see what is happening. =)

    Much appreciated, gonna look at the statement also so I can learn how it works, nothing I hate worse then not being able to find examples of something I wanna learn. =)

  10. #10
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    Ok only problem I am finding right now is that if you set it to 1 in D31, D32, D33, and D34, set to NOT Oceanic and D35 = "No" then the result comes out to 18 and correct result should be 19 so it's not adding in D31 somewhere in the Equation.

    Trying to read the equation myself to see if I can figure it out but already put it in wrong place....haha

  11. #11
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    Ok found it which actually suprised me...haha

    Correct:
    =IF(D30="Oceanic",((D32*4)+(D33*5)+(D34*9)+D31)*0.15+(D32*4)+(D33*5)+(D34*9)+D31+IF(D35="yes",4500,0),((D32*4)+(D33*5)+(D34*9)+D31)+IF(D35="Yes",4500,0))

    Yours:
    =IF(D30="Oceanic",((D32*4)+(D33*5)+(D34*9)+D31)*0.15+(D32*4)+(D33*5)+(D34*9)+D31+IF(D35="yes",4500,0),(D32*4)+(D33*5)+(D34*9)+IF(D35="Yes",4500+D31,0))

    At the end, you had the IF(D35="Yes",4500+D31,0)) so it was only adding D31 to the point total IF D35 = "Yes" so moved that to front of IF statement and it seems to be working great now.

    I can't tell you how much I appreciate your help, without it I would have been totally lost for days most likely. =)

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    In your original post, you said:

    Both False
    ((d32 * 4) + (d33 * 5) + (d34 * 9))
    There is no mention of D31 for when both are "false", i.e. Not Oceanic and No.

  13. #13
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    Oh yeah, that was my mistake but I found it thank god, didn't know if I would or not, just installed Microsoft Office 2007 and there is a nifty little Evaluate Formula button that I am gonna LOVE which is how I found and fixed the problem but I really appreciate the time and effort you put in to helping me. =)

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

    No problem..Glad to help and that it worked out in the end!

  15. #15
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    For reference (and for other users reading this post) 'Evaluate Formula' is also available in earlier versions of Excel by clicking Tools -> Formula Auditing -> Evaluate Formula.

    It can save you a lot of time troubleshooting formula errors and typos.

  16. #16
    Registered User
    Join Date
    08-15-2007
    Posts
    10
    Nice, I never knew that, been using Microsoft Office XP for years and never knew that, just installed 2007 just about an hour or two ago and trying to learn where all the buttons are for it now....lol

+ 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