Share via

Excel Hours formula

Anonymous
2023-04-23T21:43:58+00:00

Hello,

I am using the following formula.

=SUM((C1/24)*12.07%)-A1+B2

It takes the number of decimal hours (i.e 20.75) in cell A1, coverts it to hours and then calculates the holiday pay percentage on that. Takes off hours paid and previous hours due. It works just fine. Until someone is paid more than they are due. Then the formula breaks and displays infinite hash #.

How would I have to adjust the formula to make it work when the holiday pay hours due is a negative?

Thank you,

Andy

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2023-04-27T15:14:12+00:00

    Thank you so much for looking into this and your explanation is really helpful. Your workaround wouldn't really work for our requirements. But the time could be shown as a decimal rather than 24hrs, so I shall look at rebuilding the formula that way. Thanks again. Andy

    Was this answer helpful?

    0 comments No comments
  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2023-04-24T15:08:40+00:00

    Would it be possible to have the formula show a negative value?

    Andy,

    The negative value isn't the problem, your formula calculates that. However, if you format the cell with a time format, the cell will show #### because there are no negative times.

    Simple workaround:

    A1: 1:30

    B1: =-A1

    A:B formatted as time

    C1: =B1*24

    C formatted as number

    Another way:

    C1: =ABS(B1)

    C formatted as time + a conditional formatting the makes the font red if B is negative.

    Another way:

    B1: =-A1
    C1: =IF(B1<0,"-","")&TEXT(ABS(B1),"hh:mm")

    But now you have a text in C and can no longer calculate with this value.

    This are, more or less, the ways to go. It depends on your use case which is easiest.

    Andreas.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-04-24T11:10:28+00:00

    Dear Andreas,

    Thanks for you reply and for your help.

    However, that formula does not give a true answer. It stops at 0.00. So if someone is paid too much, the overpayment isn't accounted for. Would it be possible to have the formula show a negative value?

    There is no MIN or MAX, but the existing formula wouldn't allow for a negative answer.

    Thanks,
    Andy

    Was this answer helpful?

    0 comments No comments
  4. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2023-04-24T04:00:45+00:00

    =MAX(SUM((C1/24)*12.07%)-A1+B2,0)

    Was this answer helpful?

    0 comments No comments