=TRIM(SUBSTITUTE(SUBSTITUTE(TEXT(SUM(CHOOSE(LENB(A2:B2)-LEN(A2:B2),LEFT(A2:B2,LEN(A2:B2)-1),LEFT(A2:B2,LEN(A2:B2)-2)/24,MID(A2:B2,1,FIND("天",A2:B2)-1)+LEFT(RIGHTB(A2:B2,6),2)/24)*{1,-1}),"?天?/24;"),"/24","小时")," ","天"))
不知道这道题字符限制多少,TEXT的第二参数,用0、?、#等测试了好久,也没有好办法,总是会有很多空格,前面的汇总部分也太冗长了,而且如果题目中的“a天b小时”改用“a天b时”来表示的话,这个公式就不通了。
=========================================================================================
=TRIM(SUBSTITUTE(SUBSTITUTE(TEXT(SUM(TEXT(LEFT(A2:B2,FIND("天",A2:B2&"天")-1),"0;;;!0")*{1,-1},TEXT(RIGHTB(SUBSTITUTE(A2:B2,"小时",),2),"0;;;!0")/{24,-24}),"?天?/24;"),"/24","小时")," ","天"))
汇总部分推倒重写,一下子少了一大截,呵呵!
========================================================================================
=TRIM(TEXT(SUBSTITUTE(TEXT(SUM(TEXT(LEFT(A2:B2,FIND("天",A2:B2&"天")-1),"0;;;!0")*{1,-1},TEXT(RIGHTB(SUBSTITUTE(A2:B2,"小时",),2),"0;;;!0")/{24,-24}),"?天?/24;"),"/24","小时"),"0天;"))
把最外层的SUBSTITUTE换成TEXT,又可以少几个字符。
========================================================================================
=TEXT(SUBSTITUTE(TEXT(SUM(TEXT(IF({1;0},LEFT(A2:B2,FIND("天",A2:B2&"天")-1),RIGHTB(SUBSTITUTE(A2:B2,"小时",),2)),"0;;;!0")*{1,-1}/{1;24}),"?天?/24;"),"/24","小时"),"0天;")
汇总部分倒是少了很多,不过,这个答案应该不正确,公式结果存在空格,因为在去空格的时候,居然遭遇嵌套限制,狂汗!
=========================================================================================
=TEXT(SUBSTITUTE(TEXT(SUM(TEXT(IF({1;0},LEFT(A2:B2,FIND("天",A2:B2&"天")-1),RIGHTB(SUBSTITUTE(A2:B2,"小时",),2)),"0;;;!0")*{1,-1}/{1;24}),"#天#/24;"),"/24","小时"),"0天;")
用#解决空格问题,162字符。
=========================================================================================
=TEXT(SUBSTITUTE(TEXT(SUM(TEXT(IF({1;0},LEFT(A2:B2,FIND("天",A2:B2&"天")-1),RIGHTB(SUBSTITUTE(A2:B2,"小时",),2)),"0;;;!0")*{1,-1}/{1;24}),"#天#/24;"),"/24","小时"),"0天;;")
增加一个字符,解决可能出现0天的问题。
[ 本帖最后由 sunbin200388 于 2010-9-6 09:37 编辑 ] |