I have asked a similar question on here, and the answer is accurate and efficient, but it only work when the input is
` 1 h 1 m 1 s
format. If other formats, it will cause error.
The solution from the question
= VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A5," h ",":")," m ",":")," s",""))
My question as below:
May I know the way to convert the following inputs to the expected output?
Thanks in advance
Based on the two formulaes
= SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISNUMBER(SEARCH("m",S32)),IF(ISNUMBER(SEARCH("h",S32)),"","0h"),"0h0m")&S32," ",""),"m",":"),"h",":"),"s","")*1
and
=(IF(ISERROR(SEARCH("h",A1)),"0:","")&IF(ISERROR(SEARCH("m",A1)),"0:","")&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"h",":"),"m",":"),"s",""))+0
If the input is it
1 h 5 s
it causes error.
The result should follow the test cases as below
The simple way would be to add missing parts like:
=(IF(ISERROR(SEARCH("h",A1)),"0:","")&IF(ISERROR(SEARCH("m",A1)),"0:","")&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"h",":"),"m",":"),"s",""))+0
and then directly format it so it looks like you want it...