我需要检查多个单元格,如果所有单元格中的值都是数字,则返回TRUE。 示例:
A2,A4, A5,A8,A12,A16 <p>
目前我正在编写如下公式:
=IF(AND(ISNUMBER(A2),ISNUMBER(A4),ISNUMBER(A5),ISNUMBER(A8),ISNUMBER(A12),ISNUMBER(A16)),"All Numbers","Some not numbers")
有没有办法只用一个ISNUMBER
函数来编写公式,并将一组单元格传递给它?
答案 0 :(得分:1)
如果要检查的单元格位于连续数组中,则可以使用带有isnumber
函数的数组公式:
=ISNUMBER(A2:A5)
,然后按ctrl+shift+enter
而不是enter
。然后,当您查看单元格时,公式应该用大括号括起来,例如{=ISNUMBER(A2:A5)}
如果单元格不在连续数组中,则无效,
答案 1 :(得分:1)
如果数字只是非零和正数:
=IF(INDEX(FREQUENCY((A2,A4,A5,A8,A12,A16),0),2)=COUNTA(A2,A4,A5,A8,A12,A16),"All Numbers","Some not numbers")
否则:
=IF(SUM(COUNTIF(INDIRECT({"A2","A4","A5","A8","A12","A16"}),{">=0";"<0"}))=COUNTA(INDIRECT({"A2","A4","A5","A8","A12","A16"})),"All Numbers","Some not numbers")
如果您执行此检查的单元格范围是固定的,而不是动态的,那么我们可以将这些缩短为:
=IF(INDEX(FREQUENCY((A2,A4,A5,A8,A12,A16),0),2)=6,"All Numbers","Some not numbers")
或:
=IF(SUM(COUNTIF(INDIRECT({"A2","A4","A5","A8","A12","A16"}),{">=0";"<0"}))=6,"All Numbers","Some not numbers")
此致
答案 2 :(得分:0)
答案 3 :(得分:0)
COUNT
函数仅计算数字(不是文本或错误值或逻辑值或空白),因此此公式将提供与具有多个ISNUMBER
函数的当前公式相同的结果
=IF(COUNT(A2,A4,A5,A8,A12,A16)=6,"All Numbers","Some not numbers")