Adding hours from times in one cell

Patches01

New Member
Joined
Aug 11, 2021
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi All,
In need of some help. I am trying to find the hours from times entered into one cell.
I have this so far
=IF(Sheet1!E50="N/A","",IF(Sheet1!E50<>"",(TRIM(REPLACE(Sheet1!E50,1,FIND("-",Sheet1!E50),""))-TRIM(LEFT(Sheet1!E50,FIND("-",Sheet1!E50)-1)))+TRIM(RIGHT(Sheet1!E50,FIND("-",Sheet1!E50)-1))*24,""))
However when the times for example 21:00 - 5:30, which is 21:00 for starting time of a shift & 5:30am for the end time of the shift, it gives me a total hours of 4.854, which is in correct as it is 8.5 hours
Jess21:00 - 05:3021:00 - 05:3021:00 - 05:3021:00 - 05:30
Where am I going wrong.
It works for times as follows
Cathy6:00 - 15:006:00 - 15:006:00 - 15:006:00 - 15:006:00 - 15:00
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Does everyone who is using this have MS 365 ? If they do you can use this:
Excel Formula:
=LET(tStart,TIMEVALUE(TEXTBEFORE(E50,"-")),
          tEnd,TIMEVALUE(TEXTAFTER(E50,"-")),
          IF(tEnd<tStart,tEnd+1-tStart,tEnd-tStart)*24)
 
Upvote 0
Let_a.xlsm
EFG
4With 365
521:00 - 05:308.58.5
606:00 - 15:009.09.0
76:00 - 15:009.09.0
8
4d
Cell Formulas
RangeFormula
F5:F7F5=(RIGHT(E5,5)-LEFT(E5,5)+(--LEFT(E5,5)>--RIGHT(E5,5)))*24
G5:G7G5=LET(e,RIGHT(E5,5)+0,s,LEFT(E5,5)+0,(e-s+(s>e))*24)
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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