Subtracting two numbers using Substitute

android1

Board Regular
Joined
Feb 12, 2016
Messages
69
Hi,

I have 205 (general format) in cell C13, 171.08 (general format) in C14. 205 is 205 hours, 171.08 is 171 hrs 8 minutes.
To subtract these I an using the following-> =SUBSTITUTE(TEXT(D13,"00.00"),".",":")-SUBSTITUTE(TEXT(C13,"00.00"),".",":").
My result is -9:52 (format h:mm). It should be -33:52 (33hrs 52 mins).
This formula and formatting returns the correct result in all other sheets in this workbook except this. Everything seems the same in each worksheet.

Gerry
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Thanks Jeff,

No luck. Tried that at the beginning before the Substitute formula finally solved it. All for this one particular worksheet that is.
 
Upvote 0
Please Clarify your cell references..
Your description says C13 and C14
But your formula has D13 and C13

I have 205 (general format) in cell C13, 171.08 (general format) in C14. 205 is 205 hours, 171.08 is 171 hrs 8 minutes.
To subtract these I an using the following-> =SUBSTITUTE(TEXT(D13,"00.00"),".",":")-SUBSTITUTE(TEXT(C13,"00.00"),".",":")



Anyway, since both numbers are in decimal format
I would do plain old B1-A1
Then divide that by 24 to get a real time value.
=(EndTime-StartTime)/24

And format the cell as [h]:mm
 
Upvote 0
Hi Jonmo,

Should be D13 & C13. This doesn't work for me. The numbers are pulled from a report so in my example, 171.08 (171 hrs 8 mins).
I will never have higher than .59 ie 171.6 would be 172 hours. That's why I needed the substitute formula to subtract the two.
 
Upvote 0
OK I see..

But your formula IS pulling the correct value of 33:52
The issue is that the cell is considering it a TIME of Day, not Time Elapsed.
So 33:52 is actually 1 DAY and 9 hours 52 minutes
But formatting that as a standard time h:mm is only going to show the 9:52.

Try formatting the cell as [h]:mm as suggested before..
 
Upvote 0
Yes, thank you, that was it. I did not know the brackets made a difference. When I saw [h]:mm I thought yeah, that's what I have h:mm.
Thanks for the replies. Another lesson learned.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top