+ Reply to Thread
Results 1 to 13 of 13

IF formula is too long, can it be shortened?

Hybrid View

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    IF formula is too long, can it be shortened?

    I have made an IF formula to work out starting hours on a timesheet, were lateness is rounded up.
    If somebody clocks in 3 minutes past the quarter hour they are fine, four minutes past and it goes to the next 15 minutes.
    for example: 6.03 is 6.00 start, but 6.04 is 6.15 start.
    here is the formula i have but i would like to simplify it by getting rid of every hour any saying if the time is *:03 = 6.00 and if its *.04 = 6.15.

    =IF($B$6<5.03,"5.00",IF($B$6<5.18,"5.15",IF($B$6<5.33,"5.30",IF($B$6<5.48,"5.45",IF($B$6<6.03,"6.00",IF($B$6<6.18,"6.15",IF($B$6<6.33,"6.30",IF($B$6<6.48,"6.45"))))))))

    Any ideas?????

  2. #2
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF formula is too long, can it be shortened?

    Here is a copy of what i have so far
    Attached Files Attached Files

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,074

    Re: IF formula is too long, can it be shortened?

    Here, try this:

    Formula: copy to clipboard
    =LOOKUP(B6,{0,5.03,5.18,5.33,5.48,6.03,6.18,6.33,6.48},{5,5.15,5.3,5.45,6,6.15,6.3,6.45})
    Never use Merged Cells in Excel

  4. #4
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF formula is too long, can it be shortened?

    results in =N/A

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,661

    Re: IF formula is too long, can it be shortened?

    Is the B6 formated as time?
    If yes, try this:
    =TIME(HOUR(B6),IF(MINUTE(B6)<4,0,IF(MINUTE(B6)>48,60,IF(MINUTE(B6)<19,15,IF(MINUTE(B6)<34,30,45)))),0)
    If no, we have to convert time in TEXT to TIME format.

    Edit: Post sent before finding the new post from OP with file attached. Will be back soon.
    Last edited by bebo021999; 01-24-2013 at 11:13 AM.
    Quang PT

  6. #6
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF formula is too long, can it be shortened?

    that is the closest i have had yet, i have changed to time format but would prefer it in text format so 06:30:00 is 6.30
    i also need the formula for finish times too, if possible

  7. #7
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF formula is too long, can it be shortened?

    Quote Originally Posted by bebo021999 View Post
    Is the B6 formated as time?
    If yes, try this:
    =TIME(HOUR(B6),IF(MINUTE(B6)<4,0,IF(MINUTE(B6)>48,60,IF(MINUTE(B6)<19,15,IF(MINUTE(B6)<34,30,45)))),0)
    If no, we have to convert time in TEXT to TIME format.

    Edit: Post sent before finding the new post from OP with file attached. Will be back soon.
    This formula has worked best so far, except if the time is 7:48 - it doesnt change to 8:00

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,661

    Re: IF formula is too long, can it be shortened?

    Quote Originally Posted by gordymoore5 View Post
    This formula has worked best so far, except if the time is 7:48 - it doesnt change to 8:00
    You said that if 3 minutes past the quarter is OK, that means 7:48 should be 7.45, is that right?
    By the way, does the formula with TEXT in #9 work?

  9. #9
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF formula is too long, can it be shortened?

    Yes 7.48 should be 7.45. no the text formula didnt work

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: IF formula is too long, can it be shortened?

    Where are you actually using this formula?

    I can't seem to find it anywhere in the workbook.

    I did find this similiar formula in C6:C12 on 'my play'.
    Formula: copy to clipboard

    =IF(B6<7.33,"7.30",IF(B6<7.48,"7.45",IF(B6<8.03,"8.00")))
    If posting code please use code tags, see here.

  11. #11
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF formula is too long, can it be shortened?

    the formula may be slightly different, it is formula in cells C6 and E6 i am after

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,661

    Re: IF formula is too long, can it be shortened?

    Try in C6:
    =(LEFT(B6,2)+IF(--RIGHT(TEXT(B6,".00"),2)>48,1,0))&"."&IF(OR(--RIGHT(TEXT(B6,".00"),2)<4,--RIGHT(TEXT(B6,".00"),2)>48),"00",IF(--RIGHT(TEXT(B6,".00"),2)<19,15,IF(--RIGHT(TEXT(B6,".00"),2)<34,30,45)))
    Could you pls explain the rule for finish time?

  13. #13
    Registered User
    Join Date
    01-24-2013
    Location
    Newark, UK
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: IF formula is too long, can it be shortened?

    rule is paid to nearest quarter hour.

+ 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