To count cells that contain a word anywhere in the text, use COUNTIF with asterisks: =COUNTIF(A2:A100, "*salary*"). The * stands for any characters, so the word can be at the start, in the middle or at the end. Upper and lower case don't matter.
{"cells": {"A1": "Question", "A10": "salary bonus", "A11": "Fuel", "A12": "Rent - parking", "A13": "Groceries", "A2": "Contain \"salary\"", "A3": "Contain any text", "A4": "Contain the word in D2", "A7": "Payment description", "A8": "Salary November", "A9": "Rent December", "B1": "Answer", "B2": "=COUNTIF(A8:A13,\"*salary*\")", "B3": "=COUNTIF(A8:A13,\"*\")", "B4": "=COUNTIF(A8:A13,\"*\"\u0026D2\u0026\"*\")", "D1": "Word", "D2": "rent"}, "focus": "B2", "note": "Type another word in D2, for example fuel."}
Contains a word: COUNTIF with *
Put the word between two asterisks. To use a cell instead of typed text, join the asterisks to it with &.
=COUNTIF(A2:A100, "*salary*")Cells with salary anywhere in them.=COUNTIF(A2:A100, "*"&D2&"*")Cells that contain whatever is typed in D2.Any text at all
A single asterisk matches any text, so it counts every cell that holds text and skips numbers and blanks.
=COUNTIF(A2:A100, "*")Cells that contain text.=SUMPRODUCT(--ISTEXT(A2:A100))The same with ISTEXT.Starts with or ends with
Put the asterisk only on one side.
=COUNTIF(A2:A100, "Rent*")Starts with Rent.=COUNTIF(A2:A100, "*Ltd")Ends with Ltd.Common mistakes
- The count is 0
- The asterisks are missing:
=COUNTIF(A2:A100, "salary")counts only cells that are exactly "salary". - Numbers aren't counted
- Wildcards work on text. A number like 1250 doesn't match
"*12*".
Frequently asked questions
Is COUNTIF case-sensitive?
No. "Salary", "SALARY" and "salary" all match "*salary*".
How do I count cells that contain one of several words?
Add one COUNTIF per word: =COUNTIF(A2:A100, "*rent*")+COUNTIF(A2:A100, "*lease*"), as long as one cell can't contain both.
How do I sum the amounts next to those cells?
Use SUMIF with the same criteria: =SUMIF(A2:A100, "*salary*", B2:B100). See sum if a cell contains text.