+ Reply to Thread
Results 1 to 13 of 13

If function - Too many arguments

  1. #1
    Registered User
    Join Date
    06-21-2020
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    6

    If function - Too many arguments

    Hi, i'm trying to create an if function when employees are getting to and from work.

    Basically i have four cells in the same row, first is when shifts starts, second is when employee has clocked in, third is when shift ends, and fourth is when employee has clocked out.
    When employees clock in before 8 AM or at most 20 min after 8 AM (lets say 8:16 AM) the fifth cell should write "OK", and when employee clock in at 8:21 AM or later it should be "NOT OK" in the fifth cell.
    Almost the same thing is for clocking out, if someone clock out at, lets say 5 PM, or at most 20 min earlier (4:46PM) it should write "OK", but if someone clock out at 4:39PM it should write "NOT OK". If clock in or clock out (or both) cells are empty it should be "NOT OK".
    Third (or it's maybe fourth) condition should be, if all four cells are empty, to write "NO SHIFT"
    So first two conditions are most important, rest would be good, but not important as the first two.

    I have tried something like this, but it returns with too many arguments. I have tried for first two conditions only.

    =IF(AND(C6<B6+TIME(0,20,0)),"OK","NOT OK", IF(AND( E6<D6-TIME(0,20,0)),"OK","NOT OK"))

    B6 - Shift start
    C6 - Clock in time

    D6 - Shift ends
    E6 - Clock out time


    Thanks in advance.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: If function - Too many arguments

    Welcome to the forum.

    Presumably you mean this:

    =IF(AND(C6<B6+TIME(0,20,0),E6<D6-TIME(0,20,0)),"OK","NOT OK"))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: If function - Too many arguments

    (untested) I think this may be the formula you are looking for...

    =IF(C6<B6+TIME(0,20,0),E6>D6-TIME(0,20,0)),"OK","NOT OK")

    Note: I made E6 greater than D6-TIME(0,20,0), not less than as you have it... I think that is correct.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: If function - Too many arguments

    I have tested this against your description:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The problem with your first try is that you nested your IF functions incorrectly.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Registered User
    Join Date
    04-05-2013
    Location
    dublin, Ireland
    MS-Off Ver
    Excel 2007/10
    Posts
    26

    Re: If function - Too many arguments

    already answered while i was typing.

  6. #6
    Registered User
    Join Date
    06-21-2020
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    6

    Re: If function - Too many arguments

    Thank you so much, you were all correct, but 6StringJazzer has solved everything i've had in mind I have just forgot one more thing, there is one more cell (A6), and i need to add that part in IF(B6&C6&D6&E6="","NO SHIFT", so if A6 is empty, and B6, C6, D6, E6 are also empty, then it should write "NO SHIFT", but if there is some value in A6, but other four cells are empty, it should write "ON LEAVE". I have tried to add one more IF OR, but it's not working.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: If function - Too many arguments

    Let's try this. Did a quick test.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-21-2020
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    6

    Re: If function - Too many arguments

    Wow, i did a quick test too, and it looks like it's exactly what i had in mind. Thank you very much!

  9. #9
    Registered User
    Join Date
    06-21-2020
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    6

    Re: If function - Too many arguments

    Quote Originally Posted by 6StringJazzer View Post
    Let's try this. Did a quick test.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Me again, i have noticed one problem, when C6 is empty (A6, B6, E6, D6 have some value) i get "OK", but when E6 is empty (A6, B6, C6, D6 have some value) i get "NOT OK", and i should get "NOT OK" for both. So basically only C6 is a problem, but i don't have a clue how to solve it, and why i get OK for first and NOT OK for second.

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: If function - Too many arguments

    If you take the time to provide a file that shows the error, I will take the time to figure out what's wrong. Please see yellow banner at the top of the page.

  11. #11
    Registered User
    Join Date
    06-21-2020
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    6

    Re: If function - Too many arguments

    Sure i can, i have made a sample of excel file, i have added all cells, and if function also. I have marked that cell with red color.
    So, when somebody forget to Clock Out, everything is ok, i get "NOT OK", but when somebody forget to Clock In, i get "OK", but i should get "NOT OK".

    Thanks for your help
    Attached Files Attached Files

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: If function - Too many arguments

    Here is a revised version that fixes this problem. There was no check for those two blank cells. Completely missed it.

    =IF(B2&C2&D2&E2="",IF(A2="","NO SHIFT","ON LEAVE"),IF(OR(C2="",E2="",C2>B2+TIME(0,20,0),E2<D2-TIME(0,20,0)),"NOT OK","OK"))
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    06-21-2020
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    6

    Re: If function - Too many arguments

    What can i say, thank you so much once more You can send me your paypal if you want, i would like to buy you a coffee, or a beer

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. IF Function - too many arguments
    By simmo86 in forum Excel General
    Replies: 2
    Last Post: 05-02-2017, 10:21 AM
  2. Too many arguments for the function
    By Patcheen in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-29-2016, 08:47 AM
  3. [SOLVED] IF function with more than 2 arguments.
    By SeanMck in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-21-2013, 08:37 AM
  4. [SOLVED] Too Many Arguments for This Function.
    By sander07 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-22-2013, 07:34 PM
  5. two different arguments in one IF function?
    By VAZIM in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-16-2013, 08:48 AM
  6. 10 Arguments in a function
    By noisewatter in forum Excel General
    Replies: 2
    Last Post: 04-30-2009, 01:24 PM
  7. Replies: 0
    Last Post: 06-20-2006, 10:55 AM

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