General discussion

Locked

If statment

By sweta.panchal ·
I need a formula to calculate a difference of Time A (which contains total of scheduled week hours) minus Time B (which contains total of actual week hours).
For example if Scheduled hours were 40 hours and the actual hours worked for that shift was 44 hours. The result should show (-4).

I created if statement : =IF(A-B>0, A - B, B - A). this formula does show a result in 4 but I need it show in (-4). Is this possible?

I would appreciate your help.

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by SimY In reply to If statment

Just switch the last two arguments around:

=IF(A-B>0,B-A,A-B)

Collapse -

by sweta.panchal In reply to

Poster rated this answer.

Collapse -

by chitosunday In reply to If statment

if your format is not in time format,No need an if statement just A-B. If it is a time format, you cannot show a negavite answer because excel will not allow you unless you you are willing to
convert it to text format just to maintain the presentation.

Collapse -

by sweta.panchal In reply to If statment

IF I use this if statement and instead of the answer showing up as a negative, is it possible to show the negative answer in a different color or different text?

Collapse -

by SimY In reply to If statment

If you want the negative to appear in a different colour, change the format to number and you can select the negative number in red or the number in red without the negative.

Collapse -

by pmjordan In reply to If statment

Alter your formula to: =A-B
Select cell with formula and right click, select 'Format Cells...'
In 'Category:' box, scroll down (if need be)to select 'Custom'
In 'Type:' select '#,##0'
Select entry in 'Type:' with single click.
Add '[Blue]' before '#,##0' then add semi-colon (;), next type '[Red](-#,##0)'
Line should now read: [Blue]#,##0;[Red](-#,##0)
Your result will show in Blue if positive and in Red with parenthesis and minus sign if Negative.
Custom formatting has three positions; Positive; Negative; and text

Back to Software Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums