Counting cells with text in Excel is a small task that comes up constantly in real spreadsheet work. You need to count how many cells contain a specific word, how many cells contain any text at all, how many match a pattern, or how many cells contain text while excluding numbers and blanks. Excel handles all these scenarios well โ but each requires a slightly different formula. This guide covers every approach with clear examples you can adapt for your own spreadsheets.
By the end you'll know how to use COUNTIF for specific text matches, COUNTA for any non-empty cells, COUNTIF with wildcards for partial matches, SUMPRODUCT for complex text counting, and various combinations for excluding specific values. We'll also cover common pitfalls like case sensitivity, hidden characters, and counting cells that look empty but actually contain formulas returning empty strings. Whether you're a beginner or just looking for cleaner techniques, these patterns will help.
Count all cells with any text: =COUNTIF(A1:A100, '*'). Count cells with specific text: =COUNTIF(A1:A100, 'Apple'). Count cells containing partial text: =COUNTIF(A1:A100, '*apple*'). These three formulas handle 90% of real text-counting scenarios. The asterisk wildcard matches any sequence of characters and is the key to flexible text counting.
Counts cells matching a single criterion. Best for counting specific text or pattern matches. Most versatile single function for text counting tasks.
Counts all non-empty cells regardless of content type. Counts text, numbers, formulas, errors โ everything except truly empty cells.
Counts cells matching multiple criteria. Use when you need text matches combined with conditions on other columns.
Combined with logical functions, handles complex text counting that COUNTIF can't manage easily. The power tool for unusual cases.
Let's start with COUNTIF and wildcards since this handles most text-counting needs. The asterisk (*) wildcard matches any sequence of characters, including no characters. So =COUNTIF(A1:A100, '*') counts every cell in the range that contains text โ numbers and blank cells are excluded automatically. This is the cleanest way to count text cells specifically. The asterisk by itself acts as a 'must contain text' filter.
For counting cells containing specific text, just put your search term in COUNTIF: =COUNTIF(A1:A100, 'Apple') counts cells exactly equal to 'Apple'. This is case-insensitive โ Apple, APPLE, and apple all count as matches. For partial matches, add asterisks around your search term: =COUNTIF(A1:A100, '*apple*') counts cells containing 'apple' anywhere โ pineapple, applesauce, and crab apple would all count. The asterisks work like 'anything before' and 'anything after' the search term.
The question mark (?) wildcard matches exactly one character. =COUNTIF(A1:A100, '?at') counts cells with three letters ending in 'at' โ cat, bat, hat would match but at or chat would not. The asterisk and question mark can be combined: =COUNTIF(A1:A100, 'a*?*z') counts cells starting with 'a' and ending with 'z' with at least one character in between. Wildcards in COUNTIF dramatically expand what's possible with text counting.
=COUNTIF(A1:A100, '*') counts cells containing text only. Numbers, dates, and blanks are excluded. The cleanest way to get a count of text-containing cells.
=COUNTIF(A1:A100, 'Apple') counts cells exactly equal to Apple. Case-insensitive by default. The most common use of COUNTIF for text.
=COUNTIF(A1:A100, '*apple*') counts cells containing 'apple' anywhere. The asterisks act as wildcards for any characters before or after.
=COUNTIF(A1:A100, 'Apple*') counts cells starting with 'Apple'. Anything can follow but the cell must begin with 'Apple'.
=COUNTIF(A1:A100, '*Apple') counts cells ending with 'Apple'. Anything can precede but the cell must end with 'Apple'.
COUNTA differs from COUNTIF in important ways. COUNTA counts ALL non-empty cells, including cells containing numbers, dates, formulas, and even error values. It's not specifically a text-counting function โ it's an everything-non-empty function. Use COUNTA when you want to count any cell with content, not just text cells. =COUNTA(A1:A100) returns the count of cells in the range that have any value at all.
The difference matters when your range contains a mix of text, numbers, and blanks. =COUNTIF(A1:A100, '*') counts only text cells. =COUNTA(A1:A100) counts text plus numbers plus everything else non-empty. =COUNT(A1:A100) counts only numeric cells. Each function has its own purpose โ pick the one matching what you actually want to count. The right function selection prevents most common counting mistakes.
Cells that look empty but aren't are a frequent source of confusion. A formula like =IF(A1='', '', A1*2) returns an empty string when A1 is blank โ but the empty string isn't truly empty. COUNTA will count this as non-empty even though it visually appears blank. To count truly empty cells: =COUNTBLANK(A1:A100). To count visually-empty cells including those with empty string formula results, you need a more complex formula like =SUMPRODUCT(--(LEN(A1:A100)=0)).
COUNTIF is case-insensitive. For case-sensitive counting: =SUMPRODUCT(--EXACT(A1:A100, 'Apple')) counts only 'Apple' exactly (not 'APPLE' or 'apple').
=COUNTIFS(A:A, '*apple*', B:B, 'Active') counts cells where column A contains 'apple' AND column B equals 'Active'. Combine text and other conditions.
=SUMPRODUCT(1/COUNTIF(A1:A100, A1:A100)) returns the count of unique values in the range. Or use COUNTA(UNIQUE(A1:A100)) in newer Excel versions.
Numbers stored as text are tricky. =SUMPRODUCT((LEN(A1:A100)>0)*ISNUMBER(SEARCH('1', A1:A100))) counts text cells containing the digit 1.
SUMPRODUCT enables complex text counting beyond what COUNTIF can handle. The pattern uses logical expressions that return TRUE/FALSE arrays, converted to 1s and 0s using the double-negative (--) operator, then summed. =SUMPRODUCT(--(LEN(A1:A100)>0)) counts non-empty cells using length. =SUMPRODUCT(--ISTEXT(A1:A100)) counts text-only cells using ISTEXT. Each pattern lets you combine criteria that simple COUNTIF can't express.
For counting words within cells rather than counting cells with words, the LEN and SUBSTITUTE combination works well. =LEN(A1)-LEN(SUBSTITUTE(A1, ' ', ''))+1 counts words in cell A1 (assuming words separated by single spaces). To count occurrences of a specific word across a range: =SUMPRODUCT((LEN(A1:A10)-LEN(SUBSTITUTE(A1:A10, 'apple', '')))/LEN('apple')) counts total occurrences of 'apple' across all cells, including multiple occurrences within single cells.
Counting cells with specific text length is another common need. =SUMPRODUCT(--(LEN(A1:A100)=5)) counts cells containing exactly 5 characters. =SUMPRODUCT(--(LEN(A1:A100)>10)) counts cells with more than 10 characters. These patterns are useful for finding data quality issues โ short cells that should have full content, or unusually long cells that may have data entry problems.
=COUNTIFS(A:A, '*apple*', B:B, '>100') counts rows where column A contains 'apple' and column B exceeds 100. Both conditions must be met. Common for filtering categorical and numeric data simultaneously.
=COUNTIFS(A:A, 'Active', B:B, '>=1/1/2026', B:B, '<2/1/2026') counts Active items dated in January 2026. Date ranges use two conditions on the same column.
=COUNTIFS(A:A, 'Premium', B:B, 'West') counts rows that are both Premium and West. Add more criteria pairs to narrow further.
=COUNTIF(A:A, '<>Apple') counts cells not equal to 'Apple'. Note the operator must be in quotes. The <> operator means 'not equal to'.
COUNTIFS only handles AND. For OR: =COUNTIF(A:A, 'Apple') + COUNTIF(A:A, 'Banana'). Or use SUMPRODUCT for complex OR: =SUMPRODUCT(((A1:A100='Apple')+(A1:A100='Banana'))>0).
Case-sensitive text counting requires either EXACT or SUMPRODUCT since COUNTIF is always case-insensitive. =SUMPRODUCT(--EXACT(A1:A100, 'Apple')) returns the count of cells exactly matching 'Apple' with case sensitivity. EXACT returns TRUE only when text matches in all respects including case. The double-negative converts TRUE/FALSE to 1/0 for SUMPRODUCT to sum. This is the standard pattern for case-sensitive counting in Excel.
For counting unique text values in a range, the classic formula is =SUMPRODUCT(1/COUNTIF(range, range)). This works by counting each value's frequency, then summing the reciprocals โ each unique value contributes 1 to the total regardless of how many times it appears. Newer Excel versions with dynamic arrays have a cleaner approach: =COUNTA(UNIQUE(range)) returns the count of distinct values directly. If you're on a modern Excel version, prefer the UNIQUE approach for clarity.
Common pitfalls with text counting include leading or trailing spaces. ' Apple' (with leading space) won't match 'Apple' in COUNTIF unless you use wildcards: =COUNTIF(A1:A100, '*Apple*'). Or clean the data first using =TRIM(A1) to remove extra spaces. Hidden characters like non-breaking spaces (CHAR(160)) also cause mismatches. If your counts seem wrong, paste a 'matching' cell into a fresh cell and compare character by character. =EXACT(A1, B1) returns TRUE only when both cells match exactly.
Performance matters when counting in large datasets. COUNTIF and COUNTIFS use optimized internal algorithms that handle ranges of millions of cells efficiently. SUMPRODUCT formulas with array operations can be much slower on very large datasets because they evaluate each cell individually. If a sheet is recalculating slowly, look for SUMPRODUCT formulas operating on large ranges and consider whether COUNTIF/COUNTIFS combinations could achieve the same result with better performance.
Excel Tables (Insert > Table) make text counting formulas more readable and maintainable. Instead of =COUNTIF(A2:A100, '*apple*'), you'd write =COUNTIF(Sales[Product], '*apple*'). The Table reference automatically expands as you add data, eliminating the need to update ranges when data grows. This is genuinely worth the small setup time on any spreadsheet you'll maintain over time. Structured references read more like natural language too, which helps when revisiting old worksheets months later.
For dashboards and reports, the COUNTIF approach combined with dropdown lists creates powerful interactive counts. Set up a dropdown using Data Validation, then reference the selected value in COUNTIF: =COUNTIF(Sales[Region], B2) where B2 contains a dropdown. Users can change the dropdown and the count updates automatically. This pattern eliminates the need for filters in many cases and creates more polished dashboards. Combining this with conditional formatting produces dashboards that highlight the right things automatically based on user selections.
One final note on counting strategies: when you find yourself writing complex SUMPRODUCT or array formulas for text counting, consider whether a pivot table would be simpler. Pivot tables excel at categorical counts โ drag your text field into both Rows and Values areas and Excel produces a count by category automatically. For repeated categorical counting needs, pivot tables often beat individual COUNTIF formulas for both ease of creation and ease of maintenance over time. The right tool depends on whether you need formula results in specific cell positions or just need to see the counts visually.
For Excel users who frequently need to count specific text patterns, building a small reference of common patterns saves time. Keep a personal Excel file with examples of text counting formulas for the patterns you use most. Title each pattern clearly, include an example range with sample data, and show the formula along with the result. Coming back to this reference is faster than rebuilding patterns from memory each time. Many experienced Excel users maintain similar reference files for VLOOKUP variations, SUMIF patterns, and other commonly-used but easy-to-forget syntax.
The bottom line for counting cells with text: COUNTIF with wildcards handles most cases efficiently. COUNTA counts everything non-empty when type doesn't matter. COUNTIFS handles multiple conditions. SUMPRODUCT with EXACT handles case sensitivity and other unusual cases. Master COUNTIF first since it's the workhorse. Add the other techniques as specific needs arise. Within an hour of focused practice you can become genuinely fluent with these counting patterns โ and they'll serve you for every spreadsheet you ever build going forward.
Beyond simple COUNTIF, there are several broader patterns worth knowing for text analysis. The COUNTIF function with criteria from another cell is one of the most powerful patterns: =COUNTIF(A:A, B2) counts occurrences of whatever value is in B2. Combine with a list of search terms and you can build a frequency table for any number of categories at once. Drag the formula down a list of category names and each row shows the count for its category โ essentially a manual pivot table built with formulas.
The text manipulation functions LEFT, RIGHT, and MID combine with COUNTIF for prefix and suffix analysis. =SUMPRODUCT(--(LEFT(A1:A100, 3)='ABC')) counts cells where the first three characters are 'ABC'. =SUMPRODUCT(--(RIGHT(A1:A100, 4)='.com')) counts cells ending in '.com'. These patterns let you analyze structured text like product codes, email addresses, or file names without writing complex regular expressions.
For real-world data analysis, the FIND and SEARCH functions complement COUNTIF when you need more flexibility than wildcards provide. =SUMPRODUCT(--ISNUMBER(SEARCH('apple', A1:A100))) counts cells containing 'apple' case-insensitively. =SUMPRODUCT(--ISNUMBER(FIND('apple', A1:A100))) counts cells containing 'apple' case-sensitively. The SEARCH function is case-insensitive and supports wildcards. The FIND function is case-sensitive and doesn't support wildcards. Choose based on your needs.
One area worth understanding deeply: COUNTIF's behavior with errors. If your range contains #N/A, #VALUE!, or other error values, COUNTIF generally ignores them (returns 0 for that cell rather than propagating the error). However, COUNTIF will return an error if the criterion itself is an error. To safely count text in ranges that might contain errors, wrap with IFERROR: =SUMPRODUCT(IFERROR((LEN(A1:A100)>0)*1, 0)). This treats error cells as not containing text, which is usually the desired behavior.
The pivot table approach to counting deserves a worked example. Suppose you have a sales spreadsheet with hundreds of rows including columns for Product, Region, and Status. To count rows by Product and Status: select the data, Insert > PivotTable, drag Product into Rows, Status into Columns, and Product (or any text field) into Values. Right-click in the Values area > Summarize by > Count. You now have a complete cross-tabulation of products by status, all without writing a single COUNTIFS formula. This approach scales effortlessly to thousands of rows and dozens of categories.
For text counting across multiple worksheets, the 3D reference pattern works with COUNTIF but with restrictions. =COUNTIF(Sheet1:Sheet12!A1, 'Apple') is NOT a valid syntax โ COUNTIF doesn't support 3D references directly. Instead, use SUMPRODUCT with explicit sheet references: =SUMPRODUCT(COUNTIF(Sheet1!A1, 'Apple'), COUNTIF(Sheet2!A1, 'Apple'), ...) or use a helper column approach. This is one of the few areas where COUNTIF has a real limitation compared to SUM. Plan around it when designing multi-sheet workbooks.
Power Query offers another approach for serious text analysis at scale. Power Query (Data tab > Get & Transform) lets you import data, transform it, and produce summary tables that update with one click. For text counting across very large datasets or data from external sources, Power Query handles work that would be cumbersome with formulas. The learning curve is moderate but the payoff for analytical work is substantial. Even basic Power Query skills can transform how you handle data analysis in Excel.
To wrap up with practical advice: when you encounter unexpected counting results, start with the simplest possible verification. Pick a single cell that you expect to be counted, then verify Excel sees it the way you expect. Use =EXACT(A1, 'expected text') to verify exact match. Use =LEN(A1) to check length. Use =CODE(MID(A1, 1, 1)) to inspect the first character's ASCII code โ useful for finding non-breaking spaces or other invisible characters. These small diagnostic formulas reveal most mysteries within seconds.
Real-world text counting often involves messy data from external sources. Inconsistent capitalization, leading and trailing spaces, mixed languages, special characters, and various date formats all complicate counting. Before writing analytical formulas, invest time in cleaning the data using TRIM, CLEAN, PROPER, UPPER, LOWER, and SUBSTITUTE functions. A 30-minute data cleaning step often saves hours of debugging confusing count results later. Data quality is the unsung foundation of reliable analysis.
One final tip worth remembering: when you need to share a worksheet with others who may modify it, document your counting formulas with comments or a separate notes section explaining what each formula does and why. Six months from now, someone (possibly you) will need to understand the logic.
A simple cell note saying 'Counts unique customers with active accounts in the West region' takes seconds to write and saves hours of future confusion. Spreadsheets without documentation become liabilities once the original author moves on or simply forgets the reasoning behind specific formulas, named ranges, and analytical assumptions baked into the file over time as the workbook continues to evolve through ongoing use across the months and years that follow after the original creation and the initial deployment of the workbook.