+ Reply to Thread
Results 1 to 10 of 10

Trying to create a formula that rounds up when its needed to.

  1. #1
    Registered User
    Join Date
    10-31-2013
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Talking Trying to create a formula that rounds up when its needed to.

    Afternoon Guys,

    This is my first post, on, well, any forum ever! So be nice!

    I'm creating an electronic timesheet and I've hit a brick wall. So far what i have done is create start and end times. I have formatted these to be time (HH:MM) with the range between 00:00 to 23:59.

    Some of our employees work over night. I figured when they get to 23:59 on day one, they could go down a row and start day two as 00:00. This of course caused a problem for me as my totals box will now read a minute less, so 0:59.

    Because of this I have tried writing a formula that will only round up when the time is over 0:30.

    For instance,

    If someone entered anything under 0:30 it will not round up. If someone enters anything over 0:30 it will round up to a whole hour. This worked.

    I sent the completed timesheet to my boss who decided it would be better to set it to 15 minute increments rather than the previous 30 minutes. I've tried to change the formula to accomodate it but i'm having no joy.

    The formula is as follows: -

    - =IF(AND(((I10-H10)*24)>0,((I10-H10)*24)<0.16,G10="X"),"0.15",IF(AND(((I10-H10)*24)>0.15,((I10-H10)*24)<0.31,G10="X"),"0.30",IF(AND(((I10-H10)*24)>0.30,((I10-H10)*24)<0.46,G10="x"),"0.45",IF(AND(((I10-H10)*24)>0.45,ROUNDUP(((I10-H10)*24),1),""))

    What am I doing wrong? Any help would be appreciated!

  2. #2
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Trying to create a formula that rounds up when its needed to.

    Welcome to the forum!

    My suggestion is: use the built-in time functions.
    A1 = timevalue
    B1 = TIME( Hour(A1), Roundup( Minute(A1) / 15, 0) * 15, 0)

    This will roundup to the nearest 15 minute increment.

    Some of our employees work over night. I figured when they get to 23:59 on day one, they could go down a row and start day two as 00:00. This of course caused a problem for me as my totals box will now read a minute less, so 0:59.
    My approach would be to go from time values to date+time in the cell. Then you can subtract one from the next without having to roll over.

  3. #3
    Registered User
    Join Date
    10-31-2013
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Trying to create a formula that rounds up when its needed to.

    Hi Ben,

    I don't think i'm familiar with the 'timevalue' function.

    I've attached a picture of my timesheet. Would you be so kind as to explain how i could use it?

    Thanks again!

    Willexcel.JPG

  4. #4
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Trying to create a formula that rounds up when its needed to.

    ...Ah, I should have been more specific.

    I meant that A1 is the time value you want to assess; it's the hh:mm range. Not that you need the TIMEVALUE function.

    So for example,
    If the user input is
    A1 = 4:13
    Then the formula would output
    B1 = 4:15

    For you specifically...
    If H column is the start time,
    H10 = "start time"
    And I column is the end time,
    I10 = "end time"
    then the time value you need is just I10 - H10

    So then if you want column L to have the that amount rounded up by 15 minutes, you would put in:
    L10 = TIME( Hour(I10 - H10), Roundup( Minute(I10 - H10) / 15, 0) * 15, 0)


    Also...
    It's more helpful to us if you attach the XLS you're working with, rather than just a screencap JPG or whatever.

  5. #5
    Registered User
    Join Date
    10-31-2013
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Trying to create a formula that rounds up when its needed to.

    Thanks Ben,

    Great help!

    I'll be sure to do that next time.

    Will

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Trying to create a formula that rounds up when its needed to.

    Try this
    =IF(I10>H10, I10-H10, I10+1-H10)
    That will fix your missing minute.

    To round to nearest 15 minutes
    =MROUND(IF(I10>H10, I10-H10, I10+1-H10), 15/(24*60))
    To round up
    =CEILING(IF(I10>H10, I10-H10, I10+1-H10), 15/(24*60))
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Registered User
    Join Date
    10-31-2013
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Trying to create a formula that rounds up when its needed to.

    Hi ChemistB,

    It makes sense to me. I've inputted it into the relevant cell and nothing :/

    What could I be doing wrong here??

    Thanks,

    Will

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Trying to create a formula that rounds up when its needed to.

    Not sure, take a look at this. If you still are having problems, upload (Go Advanced>Manage Attachments) a sample spreadsheet.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-31-2013
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Trying to create a formula that rounds up when its needed to.

    Thanks for all your help gents!

    Sorry for the late reply.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Trying to create a formula that rounds up when its needed to.

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Formula needed to create a date entry
    By Spaz1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-19-2013, 07:23 AM
  2. [SOLVED] I need a formula that rounds up the date.
    By VivatMartin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2012, 08:44 AM
  3. Need a way to randomly create rounds for a competition
    By smaitland in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-04-2012, 12:07 PM
  4. Replies: 5
    Last Post: 05-12-2009, 09:37 AM
  5. [SOLVED] I need a %age increase formula that rounds up to the nearest $10
    By Chopper_Haynes in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-04-2005, 02:05 PM

Tags for this Thread

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