## You are learning Functions and Formulas in MS Excel

How do I count cells with the COUNTIF function?

The `COUNTIF` function in Excel is a handy tool for counting the number of cells within a specific range that meet a single criterion. Here's how to use it:

Syntax:

```excel

=COUNTIF(range, criteria)

```

Arguments:

* range: This is the cell range you want to evaluate. It can be a single cell, a continuous range of cells (e.g., A1:B10), or even a named range you've defined.

* criteria: This defines the condition for counting cells. It can be:

* A number: The function will count cells that contain the exact same number as the criteria.

* Text: The function will count cells that contain the exact same text string as the criteria. Text needs to be enclosed in double quotes (e.g., "apple").

* Logical comparison: You can use comparison operators like `>`, `<`, `>=`, `<=`, `<>` (not equal) to compare cell values with a specific number. For example, `=COUNTIF(A1:A10, ">50")` will count cells in A1:A10 that have values greater than 50.

* Wildcards: You can use wildcards like asterisk (*) or question mark (?) within the text criteria for broader matching.

* Asterisk (*) replaces any sequence of characters. For instance, `=COUNTIF(A1:A10, "b*")` will count cells containing text that starts with "b" (e.g., "ball", "bat").

* Question mark (?) replaces a single character. For example, `=COUNTIF(A1:A10, "col?")` will count cells containing text "color" or "cold".

Examples:

* Count the number of cells in A1:A10 that contain the number 25:

```excel

=COUNTIF(A1:A10, 25)

```

* Count the number of cells in B1:B5 that contain the text "apple" (case-sensitive):

```excel

=COUNTIF(B1:B5, "apple")

```

* Count the number of cells in C2:C12 that have a value greater than 100:

```excel

=COUNTIF(C2:C12, ">100")

```

* Count the number of cells in D3:D15 that contain text starting with "Prod" (case-insensitive):

```excel

=COUNTIF(D3:D15, "Prod*")

```

Tips:

* Remember to enclose text criteria in double quotes.

* For logical comparisons, ensure the comparison operator is within the quotes along with the value (e.g., ">50" not just 50).

* Wildcards can be useful for finding specific patterns within text data.

* `COUNTIF` is a versatile function, but it can only handle one criteria at a time. If you need to count cells based on multiple conditions, consider using the `COUNTIFS` function.