在 Excel 2007 中,可以用以下公式满足题述要求:
1. 非数组公式:=IF(B2>110,IF(D2<=9%,"不置休",IF(AND(D2>9%,D2<=18%),"2小时",IF(AND(D2>18%,D2<=30%),"4小时",IF(AND(D2>30%,D2<=100%),"6小时","")))),IF(C2<=7,"不置休",IF(AND(C2>7,C2<=12),"2小时",IF(AND(C2>12,C2<=17),"4小时",IF(AND(C2>17,C2<=110),"6小时","")))))
2. 数组公式:=IF(B2>110,LOOKUP(D2,({0,9.01,18.01,30.01})%,{0,2,4,6}),LOOKUP(C2,{0,7.01,12.01,17.01},{0,2,4,6}))&"小时"
注:数组公式虽然简单,但不能完全满足题述的要求,“不置休”显示为“0小时”
公式的结果如下图示:
公示结果的图示
首先,D6和D7写反了,建议用公式来完成:先清除D2及下边的数据,在D2位置输入【=C2/B2】,下拉将公式应用在多行。
对于需求,可以使用三元表达式,将以下内容写在E2,下拉即可:
=IF(AND(C5/B5<=0.09,C5<7),"不休置", IF(AND(C5/B5<=0.18,C5<=12), "休置2小时", IF(AND(C5/B5<=0.3,C5<=17), "休置4小时", IF(AND(C5/B5<=1,C5<=110), "休置6小时", "未定义"))))
E2用公式:
=IF(B2>110,LOOKUP(D2,({9,17,30}+0.0001)%,{2,4,6}),LOOKUP(C2,{7,12,110}+0.0001,{2,4,6}))&"小时"
下拉。