Calculating Time

Afaes

New Member
Joined
Dec 11, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi All, can you please help me with the following question:

I can’t figure out how to calculate the time in Column A to get 8hrs in Column B. Is there a formula I can use in Column B that will give me 8hrs? Thanks!


Column A Column B
7am - 3pm ??
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
A09760BC-9ED0-4AA4-B126-0EA7397E182D.png
 
Upvote 0
Welcome to the MrExcel board!

Is this what you want?

21 12 12.xlsm
AB
1ScheduleHours
27am-3pm8
Hours
Cell Formulas
RangeFormula
B2B2=LET(t,SUBSTITUTE(SUBSTITUTE(A2,"a"," a"),"p"," p"),x,FIND("-",t),24*(REPLACE(t,1,x,"")-LEFT(t,x-1)))
 
Upvote 0
Thank you- When I tried that formula this appeared in cell B2: #NAME?
 
Upvote 0
When I tried that formula this appeared in cell B2: #NAME?
Sounds like you do not have the LET function in your copy of MS365.
Try this instead then.

21 12 12.xlsm
AB
1ScheduleHours
27am-3pm8
Hours (2)
Cell Formulas
RangeFormula
B2B2=24*(REPLACE(SUBSTITUTE(SUBSTITUTE(A2,"a"," a"),"p"," p"),1,FIND("-",SUBSTITUTE(SUBSTITUTE(A2,"a"," a"),"p"," p")),"")-LEFT(SUBSTITUTE(SUBSTITUTE(A2,"a"," a"),"p"," p"),FIND("-",SUBSTITUTE(SUBSTITUTE(A2,"a"," a"),"p"," p"))-1))
 
Upvote 0
Solution
You're welcome. Thanks for the confirmation.
 
Upvote 0
One more question if you don’t mind. How would I get the total hours from Sunday - Saturday (all working 7am-3pm) to say 56hrs instead of 8??

Thank you
 
Upvote 0
For instance, A2 is Sunday, then B2 is Monday and so forth. How would I get H2 to say 56hrs?
 
Upvote 0
Can you show us (preferably with XL2BB) some actual sample data and expected result so that we can be sure of the layout and format of it?
 
Upvote 0

Forum statistics

Threads
1,216,774
Messages
6,132,649
Members
449,740
Latest member
Stevejhonsy

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