This example will teach you how to count the number of occurrences of text in a selected range.
- For example, you can count the number of cells containing the text “star” using the following formula:
=COUNTIF(A1:A7,"star")
=СЧЁТЕСЛИ(A1:A7;"star")
- To count the number of cells containing “star” + 1 character, this formula is suitable:
=COUNTIF(A1:A7,"star?")
=СЧЁТЕСЛИ(A1:A7;"star?")
The question mark (?) matches exactly one character.
- You can calculate the number of cells containing “star” + a number of characters (from zero or more) using the formula below:
=COUNTIF(A1:A7,"star*")
=СЧЁТЕСЛИ(A1:A7;"star*")
An asterisk (*) matches a range of characters (zero or more).
- You can also count the number of cells that contain “star” anyway, using this formula:
=COUNTIF(A1:A7,"star*")
=СЧЁТЕСЛИ(A1:A7;"*star*")
This function counts all cells that contain “star”, regardless of what comes before or after the search text.
- You can also count the number of cells containing any text by writing this formula:
=COUNTIF(A1:A7,"*")
=СЧЁТЕСЛИ(A1:A7;"*")