Excel中COUNTIF函數(shù)的使用方法
Countif函數(shù)是Microsoft Excel中對指定區(qū)域中符合指定條件的單元格計數(shù)的一個函數(shù),在WPS,Excel2003和Excel2007等版本中均可使用。下面是相關(guān)的知識,歡迎閱讀。
【資料圖】
該函數(shù)的語法規(guī)則如下:
countif(range,criteria)
參數(shù):range 要計算其中非空單元格數(shù)目的區(qū)域
參數(shù):criteria 以數(shù)字、表達(dá)式或文本形式定義的條件
一、求各種類型單元格的個數(shù)
(1) 求真空單元格個數(shù):=COUNTIF(數(shù)據(jù)區(qū),"=")
(2) 非真空單元格個數(shù): =COUNTIF(數(shù)據(jù)區(qū),"<>") 相當(dāng)于counta()函數(shù)
(3) 文本型單元格個數(shù): =COUNTIF(數(shù)據(jù)區(qū),"*") 假空單元格也是文本型單元格
(4) 區(qū)域內(nèi)所有單元格個數(shù): =COUNTIF(數(shù)據(jù)區(qū),"<>"""),如果數(shù)據(jù)區(qū)內(nèi)有",該公式不成立.
(5) 邏輯值為TRUE的單元格數(shù)量 =COUNTIF(數(shù)據(jù)區(qū),TRUE)
二、求大于或小于某個值的單元格個數(shù)
(1) 大于50=COUNTIF(數(shù)據(jù)區(qū),">50")
(2) 等于50=COUNTIF(數(shù)據(jù)區(qū),50)
(3) 小于50 =COUNTIF(數(shù)據(jù)區(qū),"<50")
(4) 大于或等于50 =COUNTIF(數(shù)據(jù)區(qū),">=50")
(5) 小于或等于50 =COUNTIF(數(shù)據(jù)區(qū),"<=50")
(6) 大于E5單元格的值 =COUNTIF(數(shù)據(jù)區(qū),">"&$E$5)
(7) 等于E5單元格的值 =COUNTIF(數(shù)據(jù)區(qū),$E$5)
(8) 小于E5單元格的值 =COUNTIF(數(shù)據(jù)區(qū),"<"&$E$5)
(9) 大于或等于E5單元格的值 =COUNTIF(數(shù)據(jù)區(qū),">="&$E$5)
(10) 小于或等于E5單元格的值 =COUNTIF(數(shù)據(jù)區(qū),"<="&$E$5)
三、等于或包含某N個特定字符的"單元格個數(shù)
(1) 兩個字符 =COUNTIF(數(shù)據(jù)區(qū),"??")
(2) 兩個字符并且第2個是B=COUNTIF(數(shù)據(jù)區(qū),"?B")
(3) 包含B =COUNTIF(數(shù)據(jù)區(qū),"*B*")
(4) 第2個字符是B =COUNTIF(數(shù)據(jù)區(qū),"?B*")
(5) 等于“你好”=COUNTIF(數(shù)據(jù)區(qū),"你好")
(6) 包含D3單元格的內(nèi)容 =COUNTIF(數(shù)據(jù)區(qū),"*"&D3&"*")
(7) 第2字是D3單元格的內(nèi)容 =COUNTIF(數(shù)據(jù)區(qū),"?"&D3&"*")
注:countif()函數(shù)對英文字母不區(qū)分大小寫,通配符只對文本有效
四、兩個條件求個數(shù)
(1)>10并且<=15 =SUM(COUNTIF(數(shù)據(jù)區(qū),">"&{10,15})*{1,-1})
(2)>=10并且<15 =SUM(COUNTIF(數(shù)據(jù)區(qū),">="&{10,15})*{1,-1})
(3)>=10并且<=15 =SUM(COUNTIF(數(shù)據(jù)區(qū),{">=10",">15"})*{1,-1})
(4)>10并且<15 =SUM(COUNTIF(數(shù)據(jù)區(qū),{">10",">=15"})*{1,-1})或者=SUM(COUNTIF(數(shù)據(jù)區(qū),{">10",">=15"})-樣本數(shù)
注:一般多條件計數(shù)使用SUMPRODUCT函數(shù),以上方法較少使用,僅供參考。
補(bǔ)充:
三個區(qū)域計數(shù): 三個區(qū)域中>=60 =SUM(COUNTIF(INDIRECT({"a46:a48","b48:b50","c47:c48"}),">=60"))
補(bǔ)充:(集合運算法)
統(tǒng)計范圍,比如5<= x <=7
可以分解為(x>=5)-(x>7)
寫為函數(shù):
=countif(range,">=5")-countif(range,">7")
這樣就可以利用集合的運算知識了。同樣實現(xiàn)了上面兩個條件求個數(shù)相同的目的,并且更簡單易于理解。
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。