Excel中的COUNTIF怎么使用
一、求各种类型单元格的个数
(1) 求真空单元格单个数: =COUNTIF(data,"=")
(2) 真空+假空单元格个数: =COUNTIF(data,"") 相当于countblank()函数
(3) 非真空单元格个数: =COUNTIF(data,"<>") 相当于counta()函数
(4) 文本型单元格个数: =COUNTIF(data,"*") 假空单元格也是文本型单元格
(5) 区域内所有单元格个数: =COUNTIF(data,"<>""")
(6) 逻辑值为TRUE的单元格数量 =COUNTIF(data,TRUE)
小说明:
EXCEL单元格内数据主要有以下几类:数值型,文本型,逻辑型,错误值型。其中时间类型也是一种特殊的数值。文本类型的数字是文本型。
空单元格:指什么内容也没有的单元格,姑且称之为真空。
假空单元格:指0字符的空文本,一般是由网上下载来的或公式得来的,姑且称之为假空。
date指单元格区域,该参数不能是数组。
二、求><=某个值的单元格个数
(1) 大于50 =COUNTIF(data,">50")
(2) 等于50 =COUNTIF(data,50)
(3) 小于50 =COUNTIF(data,"<50")
(4) 大于或等于50 =COUNTIF(data,">=50")
(5) 小于或等于50 =COUNTIF(data,"<=50") ¬
(6) 大于E5单元格的值 =COUNTIF(data,">"&$E$5)
(7) 等于E5单元格的值 =COUNTIF(data,$E$5)
(8) 小于E5单元格的值 =COUNTIF(data,"<"&$E$5)
(9) 大于或等于E5单元格的值 =COUNTIF(data,">="&$E$5)
(10) 小于或等于E5单元格的值 =COUNTIF(data,"<="&$E$5)
三、等于或包含某N个特定字符的单元格个数
(1) 两个字符 =COUNTIF(data,"??")
(2) 两个字符并且第2个是B =COUNTIF(data,"?B")
(3) 包含B =COUNTIF(data,"*B*")
(4) 第2个字符是B =COUNTIF(data,"?B*")
(5) 等于“你好” =COUNTIF(data,"你好")
(6) 包含D3单元格的内容 =COUNTIF(data,"*"&D3&"*")
(7) 第2字是D3单元格的内容 =COUNTIF(data,"?"&D3&"*")
注:countif()函数对英文字母不区分大小写,通配符只对文本有效
四、两个条件求个数
(1) >10并且<=15 =SUM(COUNTIF(data,">"&{10,15})*{1,-1})
(2) >=10并且<15 =SUM(COUNTIF(data,">="&{10,15})*{1,-1})
(3) >=10并且<=15 =SUM(COUNTIF(data,{">=10",">15"})*{1,-1})
(4) >10并且<15 =SUM(COUNTIF(data,{">10",">=15"})*{1,-1})
注:一般多条件计数使用SUMPRODUCT函数,以上方法较少使用,仅供参考。
补充:三个区域计数:
三个区域中>=60 =SUM(COUNTIF(INDIRECT({"a46:a48","b48:b50","c47:c48"}),">=60"))
五、各种特殊统计要求的计算 A2:A32 为存放数据的区域
(1)非空文本(仅包括可键入文本) =COUNTIF(A2:A32,">=!")
(2)所有非空文本 =COUNTIF(A2:A32,">=!")+COUNTIF(A2:A32,">="&CHAR(1))-COUNTIF(A2:A32,">= ") 或 {=SUM(COUNTIF(A2:A32,">="&{"!"," "})*{1,-1})+COUNTIF(A2:A32,">="&CHAR(1))}
(3)全部可见单元格 {=SUM(N(IF(ISERROR(A2:A32),1,SUBSTITUTE(A2:A32," ",""))<>""))}
(4)有效可见单元格 =COUNTIF(A2:A32,">=!")+COUNTIF(A2:A32,">="&CHAR(1))-COUNTIF(A2:A32,">= ")+COUNT(A2:A32)
(5)全部不见单元格(真空+空格+空文本) =COUNTIF(A2:A32,"")-COUNTIF(A2:A32,">=!")+COUNTIF(A2:A32,">= ")
(6)空格 =COUNTIF(A2:A32,">= ")-COUNTIF(A2:A32,">=!")
(7)空文本"" =COUNTIF(A2:A32,"")-COUNTIF(A2:A32,"=")
(8)逻辑与错误 =COUNTIF(A2:A32,"<>")-COUNTIF(A2:A32,"*")-COUNT(A2:A32)