I have formula to extract numbers from Google XML response, that can be:
9 часов 24 минут10 h 0 min9 h 20 min11 h 13 min10 Std 55 min9 timmar 5 min19 min
Here is current formula (value is in BZ1):
=IFERROR(IF(VALUE(IF(FIND("min";BZ1;1)=11;MID(BZ1;FIND("min";BZ1;1)-2;1);MID(BZ1;FIND("min";BZ1;1)-3;2)))<30; VALUE(LEFT(BZ1;FIND("h";BZ1;1)-2))&","&5;VALUE(LEFT(BZ1;FIND("h";BZ1;1)-2))+1);"")
Formula rounds hours and minutes to hours, for example
1 h 39 min->210 h 12 min->10,59 h 20 min->9,5
There is a problem that it is not able to take in consideration language changes for hours and min.
Is there any possibility to make it work so that it will:
- If there is only number (case
19 min) -> extract number - If there are two numbers (case
1 h 39 min) -> extract first number as hours, then from last two spaces number as minutes
EDIT:
Check how many numbers in cell (target in CA25):
SUM(LEN(CA25)-LEN(SUBSTITUTE(CA25;{1;2;3;4;5;6;7;8;9};)))>1
If more than 1
LEFT(CA25;(FIND(" ";CA25;1)-1))&TRIM(MID(SUBSTITUTE(CA25;" ";REPT(" ";50));100;50))
If less than 1
LEFT(CA25;SUM(LEN(CA25)-LEN(SUBSTITUTE(CA25;{"0";"1";"2";"3";"4";"5";"6";"7";"8";"9"};""))))
All together
=IF(SUM(LEN(CA25)-LEN(SUBSTITUTE(CA25;{1;2;3;4;5;6;7;8;9};)))>1;LEFT(CA25;(FIND(" ";CA25;1)-1))&TRIM(MID(SUBSTITUTE(CA25;" ";REPT(" ";50));100;50));LEFT(CA25;SUM(LEN(CA25)-LEN(SUBSTITUTE(CA25;{"0";"1";"2";"3";"4";"5";"6";"7";"8";"9"};"")))))
This gives as output:
Now these need to be converted to hours and rounded up to one hour
EDIT 2:
Here is formula (target BZ1):
=IFERROR(IF(LEN(BZ1)-LEN(SUBSTITUTE(BZ1;" ";""))>2;LEFT(BZ1;(FIND(" ";BZ1;1)-1))+IF(TRIM(MID(SUBSTITUTE(BZ1;" ";REPT(" ";50));100;50))<60;1;1);IF(LEFT(BZ1;SUM(LEN(BZ1)-LEN(SUBSTITUTE(BZ1;{"0";"1";"2";"3";"4";"5";"6";"7";"8";"9"};""))))<60;1;1));"")

