Concatenate

lehy2002

New Member
Joined
Nov 3, 2016
Messages
22
I have the following data and want to make it 20:05 (20 hours and 5 minutes) However, there are some cells that are double digits such as 58 minutes. How do I create a calculation to combine the two cells and if one is a single digit add the leading 0 and if not, do not add it. In the cases below, I would want 20:05, 18:04, 14:58.

20 hours, 5 minutes
18 hours, 4 minutes
14 hours, 58 minutes
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Your post is not very clear about your setup. Using the first example, it sounds like you have "20 hours" (as text) in one cell and "5 minutes" (as text) in the other cell. If that is the case, and if those two cells are A1 and B1, then...

=LEFT(A1,FIND(" ",A1)-1)&TEXT(LEFT(B1,FIND(" ",B1)-1),"\:00")

The above is a text value. If you wanted it to be a real time value, then use this formula...

=0+(LEFT(A1,FIND(" ",A1)-1)&TEXT(LEFT(B1,FIND(" ",B1)-1),"\:00"))

and Custom Format the cell using this Type pattern... [h]:mm
 
Last edited:
Upvote 0
Not elegant, but here's one way:

Code:
=RIGHT("0"&LEFT(A2,FIND(" ",A2)-1),2)&":"&RIGHT("0"&TRIM(MID(A2,FIND(",",A2)+2,2)),2)

assuming your data starts in A2, then fill this down.
 
Upvote 0
Another possibility. Format Col B as hh:mm.
Book1
AB
120 hours, 5 minutes20:05
218 hours, 4 minutes18:04
314 hours, 58 minutes14:58
Sheet1
Cell Formulas
RangeFormula
B1:B3B1=TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"minutes",""),"hours","")," , ",":"))
 
Upvote 0
Another possibility. Format Col B as hh:mm.
Book1
AB
120 hours, 5 minutes20:05
218 hours, 4 minutes18:04
314 hours, 58 minutes14:58
Sheet1
Cell Formulas
RangeFormula
B1:B3B1=TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"minutes",""),"hours","")," , ",":"))
Hopefully, if the value was 1 that the plural of hour or minute was still used.?
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

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