zoukankan      html  css  js  c++  java
  • MS Excel: COUNTIF Function (WS)

    MS Excel: COUNTIF Function (WS)

    MS Excel: COUNTIF Function (WS)

    In Excel, the COUNTIF function counts the number of cells in a range, that meets a given criteria.

    The syntax for the COUNTIF function is:

    COUNTIF( range, criteria )

    range is the range of cells that you want to count based on the criteria.

    criteria is used to determine which cells to count.

    Applies To:

    • Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

    Type of Function:

    • Worksheet function (WS)

    Worksheet Function Example:

    Let's take a look at an example to see how you would use the COUNTIF function in a worksheet:

    copyright www.TechOnTheNet.com

    Based on the Excel spreadsheet above, the COUNTIF function would return the following:

    =COUNTIF(A2:A7, D2)would return 1
    =COUNTIF(A:A, D2)would return 1
    =COUNTIF(A2:A7, ">=2001")would return 4

    Using Named Ranges

    You can also use a named range in the COUNTIF function. For example, we've created a named range called family that refers to column A in Sheet 1.

    copyright www.TechOnTheNet.com

    Then we've entered the following data in Excel:

    copyright www.TechOnTheNet.com

    Based on the Excel spreadsheet above:

    =COUNTIF(family, D2)would return 1
    =COUNTIF(family, ">=2001")would return 4

    To view named ranges: Under the Insert menu, select Name > Define.

    copyright www.TechOnTheNet.com

    Frequently Asked Questions


    Question: I'm trying to use COUNTIF on a selection of cells (not necessarily one solid range), and the syntax of the function does not allow that. Is there another way to do this?

    Here's an example of what I'd like to be able to do:

    =COUNTIF(A2,A5,F6,G9,">0")

    Answer: Unfortunately, the COUNTIF function does not support multiple ranges. However, you could try summing multiple COUNTIFs.

    For example:

    =SUM(COUNTIF(A2,">0"),COUNTIF(A5,">0"),COUNTIF(F6,">0"),COUNTIF(G9,">0"))

    OR

    =COUNTIF(A2,">0")+COUNTIF(A5,">0")+COUNTIF(F6,">0")+COUNTIF(G9,">0")


    Question: I am using the COUNTIF function and I would like to make the criteria equal to a cell.

    For example:

    =COUNTIF(C4:C19,">=2/26/04")

    I want to replace 2/26/04 with cell A1. How do I do this?

    Answer: To use a cell reference in the criteria, you could do the following:

    =COUNTIF(C4:C19,">="&A1)

  • 相关阅读:
    mac的端口被占用
    php中的运算符、控制结构
    文档模式影响浏览器的渲染
    ubuntu 命令 tips 来自于 ubuntu中文论坛
    用好 Emacs 中的 register
    [转载] Rsync命令参数详解
    使用 python 遍历目录下的文件
    灵活的左移位( << )操作
    使用 iperf 测试两台机器间的最大带宽
    Emacs server 新启动方式 (仅在emacs daemon未启动时才启动daemon)
  • 原文地址:https://www.cnblogs.com/lexus/p/2698685.html
Copyright © 2011-2022 走看看