convert digits to time

oravec

Board Regular
Joined
Apr 15, 2003
Messages
65
Hello,

Is there an easy way to enter time as 1200 for 12:00 or 30 for 00:30. And use macro to convert all digits to hh:mm format.

Basically I want to be able to enter values without a colon and use macro to convert to time, regardless to what 1, 2, 3 or 4 digits I enter.

I made huge search and replace macro, but know there must be an easier way.

Cliff
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You could use a formula approach such as
=(LEFT(TEXT(A1,"0000"),2)&":"&RIGHT(TEXT(A1,"00"),2))+0

and format as hh:mm

or incorporate the same into a macro.

Also
=SUM(MID(TEXT(A1,"0000"),{1,3},2)/{24,1440}) formatted as hh:mm

Okay last edit. Stolen from someone else, can't remember who:

Use
=TEXT(A3,"00\:00")+0

and format as time.
 
Upvote 0
Thank you,

That is exactly what I was looking for. It will allow me to get rid of my HUGE search and replace macro's.

Cliff
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,685
Members
449,463
Latest member
Jojomen56

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