+ Reply to Thread
Results 1 to 5 of 5

Nested if statements with AND and OR statements

  1. #1
    Registered User
    Join Date
    02-08-2010
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    47

    Nested if statements with AND and OR statements

    =IF(G4="H",AI3,IF(OR(AND(D4="JAN",G4>=20),AND(D4="FEB",G4<=11),AND(D4="FEB",G4>=20),AND(D4="APR",G4<=4),AND(D4="OCT",G4>=7),AND(D4="JAN",G4<=4),D4="MAR",D4="NOV",D4="DEC"),1,IF(AND(D4=”JUN”,G4>=3),AND(D4=”JUN”,G4<=18),AND(D4=”SEP”,G4>=8),AND(D4=”OCT”,G4<=6),0)))

    I keep getting the "too many arguments" error when I try to enter the above formula. Maybe I am overtired, but I cannot figure out what the heck I am screwing up here. Can anyone fix this and explain what the issue is - so I can learn this hopefully not have continued problems.

    Thank you!
    Last edited by joeljoel; 08-08-2011 at 12:58 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Nested if statements with AND and OR statements

    Without looking in great detail I suspect you are missing an OR prior to your second batch of AND tests.

    Also, you've also not specified what the result should be if neither 1 nor 0 (presently the formula would return FALSE which coerced = 0 ... i.e. I suspect you do not want that result)

  3. #3
    Registered User
    Join Date
    02-08-2010
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Nested if statements with AND and OR statements

    You were right about the "OR" - so I have fixed it
    =IF(G4="H",AI3,IF(OR(AND(D4="JAN",G4>=20),AND(D4="FEB",G4<=11),AND(D4="FEB",G4>=20),AND(D4="APR",G4<=4),AND(D4="OCT",G4>=7),AND(D4="JAN",G4<=4),D4="MAR",D4="NOV",D4="DEC"),1,IF(OR(AND(D4=”JUN”,G4>=3),AND (D4=”JUN”,G4<=18),AND(D4=”SEP”,G4>=8),AND(D4=”OCT”,G4<=6)),-1,0)))

    I still get a general error though. What I am looking for is if any of the conditions or pairs of conditions (essentially testing if the workday occurs between several pairs of two dates) occur in the first OR statement, return a 1. Otherwise, are the next set of conditions after the next OR true, if so, enter -1, if neither is set of conditions is true enter a 0.

    This shouldn't be that hard, I don't think - I am frustrated I cannot figure this one out. Maybe too many AND's and OR's? Is there a simpler way to do this?

    Thank you

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Nested if statements with AND and OR statements

    Syntax wise this appears ok:

    Please Login or Register  to view this content.
    Though I confess I've not reviewed the logic in any detail.

  5. #5
    Registered User
    Join Date
    02-08-2010
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Nested if statements with AND and OR statements

    That works, although when I put them both side by side in a Word doc, I cannot find any difference - other than the type of quotes from Word is slightly different. Could this be an issue?

    Anyway, I'm not complaining - just puzzled. Hopefully I can use this for a template as I have 4 more similar columns to do, just with different date ranges.

    Thanks again, DonkeyOte

+ 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