395 | COUNTIF函數常規用法 | ||||
示範檔 | 無 | 範例檔 | 395.XLSX | 結果檔 | 無 |
n 一、求各種類型儲存格的個數
(1)求真空儲存格單個數:=COUNTIF(DATA,"=")
(2)真空+假空儲存格個數:=COUNTIF(DATA,"")相當於COUNTBLANK()函數
(3)非真空儲存格個數:=COUNTIF(DATA,"<>")相當於COUNTA()函數
(4)文字型儲存格個數:=COUNTIF(DATA,"*")假空儲存格也是文字型儲存格
(5)區域內所有儲存格個數:=COUNTIF(DATA,"<>""")
(6)邏輯值為TRUE的儲存格數量:=COUNTIF(DATA,TRUE)
小說明:
Excel儲存格內資料主要有以下幾類:數值型,文字型,邏輯型,錯誤值型。
其中時間類型也是一種特殊的數值。
文字類型的數值是文字型。
空儲存格:指什麼內容也沒有的儲存格,姑且稱之為真空。
假空儲存格:指0字元的空文字,一般是由網上下載來的或公式得來的,姑且稱之為假空。
DATA指儲存格範圍,該參數不能是陣列。
n 二、求><=某個值的儲存格個數
(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 三、等於或包含某N個特定字元的儲存格個數
(1)兩個字元:=COUNTIF(DATA,"??")
(2)兩個字元並且第2個是D:=COUNTIF(DATA,"?D")
(3)包含F:=COUNTIF(DATA,"*F*")
(4)第2個字元是R:=COUNTIF(DATA,"?R*")
(5)等於“你好”:=COUNTIF(DATA,"你好")
(6)包含D3儲存格的內容:=COUNTIF(DATA,"*"&D3&"*")
(7)第2字是S3儲存格的內容:=COUNTIF(DATA,"?"&S3&"*")
注意:COUNTIF()函數對英文字母不區分大小寫,萬用字元只對文字有效。
n 四、兩個條件求個數
(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
n 五、各種特殊統計要求的計算A1:A100為存放資料的區域
(1)非空文本(僅包括可鍵入文本:=COUNTIF(A1:A100,">=!")
(2)所有非空文本=COUNTIF(A1:A100,">=!")+COUNTIF(A1:A100,">="&CHAR(1))–COUNTIF( A1:A100,">=")或{=SUM(COUNTIF(A1:A100,">="&{"!",""})*{1,-1}) + COUNTIF(A1:A100,">="&CHAR(1))}即文字型-含" "(空格)數量
(3)全部可見儲存格{=SUM(N(IF(ISERROR(A1:A100),1,SUBSTITUTE(A1:A100," ",""))<>""))},即全部看上去不是空值的儲存格(=全部記錄-真空-空格)
(4)有效可見儲存格=COUNTIF(A1:A100,">=!")+COUNTIF(A1:A100,">="&CHAR(1)) -COUNTIF(A1:A100,">= ")+COUNT(A1:A100),即所有非空文+數字型資料之和
(5)全部不見儲存格(真空+空格+空文本)=COUNTIF(A1:A100,"")+COUNTIF(A1:A100,">=!") +COUNTIF(A1:A100,">=")
(6)空格=COUNTIF(A1:A100,">=")-COUNTIF(A1:A100,">=!")
(7)空文本""=COUNTIF(A1:A100,"")-COUNTIF(A1:A100,"=")
(8)邏輯與錯誤=COUNTIF(A1:A100,"<>")-COUNTIF(A1:A100,"*")-COUNT(A1:A100)
留言列表