用法
一、求各種類型單元格的個數
(1) 求真空單元格個數:=COUNTIF(數據區,"")
(2) 非真空單元格個數: =COUNTIF(數據區,"") 相當於counta()函式
(3) 文本型單元格個數: =COUNTIF(數據區,"*") 假空單元格也是文本型單元格
(4) 區域內所有單元格個數: =COUNTIF(數據區,""""),如果數據區內有",該公式不成立.
(5) 邏輯值為TRUE的單元格數量 =COUNTIF(數據區,TRUE)
二、求大於或小於某個值的單元格個數
(1) 大於50=COUNTIF(數據區,">50")
(2) 等於50=COUNTIF(數據區,50)
(3) 小於50 =COUNTIF(數據區,"=50")
(5) 小於或等於50 =COUNTIF(數據區,""&$E$5)
(7) 等於E5單元格的值 =COUNTIF(數據區,$E$5)
(8) 小於E5單元格的值 =COUNTIF(數據區,"="&$E$5)
(10) 小於或等於E5單元格的值 =COUNTIF(數據區,""&{10,15})*{1,-1}) 或者=SUM(COUNTIF(數據區,"="&{10,15})*{1,-1}) 或者 =SUM(COUNTIF(數據區,"=10",">15"})*{1,-1})
(4)>10並且=60 =SUM(COUNTIF(INDIRECT({"a46:a48","b48:b50","c47:c48"}),">=60"))
補充:(集合運算法)
統計範圍,比如57)
寫為函式:
=countif(range,">=5")-countif(range,">7")
這樣就可以利用集合的運算知識了。同樣實現了上面兩個條件求個數相同的目的,並且更簡單易於理解。
特殊統計
五、各種特殊統計要求計算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)
說明
EXCEL單元格內數據主要有以下幾類:數值型,文本型,邏輯型,錯誤值型。其中時間類型也是一種特殊的數值。文本類型的數字是文本型。
空單元格:指什麼內容也沒有的單元格,姑且稱之為真空。
假空單元格:指0字元的空文本,一般是由網上下載來的或公式得來的,姑且稱之為假空。
date指單元格區域,該參數不能是數組