Converting durations to minutes

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,283
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Good morning,

I have a series of time values which are formatted thus e.g. 28hr 46m 22s

I have some code that builds up a string containing the "minute" vales of these strings, so, for example 10h 15m 17s would display as 615 (10*60+15)

I achieve this with:
Code:
MinuteValue = (Hour(Selection) * 60) + Minute(Selection)
This works fine as long as the value doesn't exceed 24 hours - 28hr 46m 22s for example returns 286 when it should be 1726 (28*60)+46
Do any of you nice folk have a suggestion as to how I can alter my code to include up the days correctly?

Thanks in advance

Pete
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi there. Try: MinuteValue = Round(MySelection * 60 * 24, 0) (I have changed the name you used as it is a word used in Excel and I always try to avoid using names like that).
 
Upvote 0
John - perfect! :-) I was only using "Selection" whilst I was testing the code manually on selected cells, but thanks for the spot nevertheless!
Pete
 
Upvote 0
You're welcome and thanks for the feedback (I was very lazy and didn't use code tags - naughty!
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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