COUNTIF Function Guide
Master the COUNTIF function to count cells that meet specific criteria. Learn syntax, practical examples, and error solutions for data analysis.



=COUNTIF(range, criteria)
Practical Examples
Count Sales Above Target
Count how many sales representatives exceeded $50,000 in quarterly revenue
Count Products by Category
Find how many products belong to the 'Electronics' category in inventory
Count Employees Using Wildcards
Count all employees whose names start with 'J' using wildcard pattern matching
Count Non-Empty Cells
Count all cells that contain any data (not blank) in a customer feedback column
Count Dates in Current Month
Count orders placed in January 2025 using date criteria
Count Cells with Partial Text Match
Find products containing 'Pro' anywhere in the product name
Common Errors and Solutions
COUNTIF returns #VALUE! error
The criteria argument contains an invalid expression or the range reference is incorrect. This often occurs with unclosed quotes or when referencing closed workbooks.
1. Check that text criteria are enclosed in quotes 2. Verify the range is valid and accessible 3. Ensure any referenced workbooks are open 4. Check for typos in formula syntax
Always enclose text and operators in quotes. Test formulas with small ranges first.
Example:
Excel doesn't recognize the function name
COUNTIF is misspelled, or you're using an Excel version that doesn't support the function (pre-Excel 97).
1. Check spelling: COUNTIF not COUTIF or COUNT IF 2. Ensure no spaces in function name 3. Verify Excel version supports COUNTIF 4. Check language settings if using non-English Excel
Use Excel's autocomplete feature when typing formulas
Example:
COUNTIF returns 0 or incorrect count
Common causes include hidden characters in cells, number/text mismatch, extra spaces, or case-sensitive expectations when COUNTIF is case-insensitive.
1. Use TRIM to remove extra spaces: =COUNTIF(A:A, TRIM(B1)) 2. Convert numbers stored as text using VALUE() 3. Check for hidden characters with LEN function 4. Remember COUNTIF is not case-sensitive
Clean data before analysis. Use Data > Text to Columns to fix number formatting.
Example:
Formula calculates very slowly
Using entire column references (A:A) with large datasets or volatile formulas that recalculate frequently.
1. Limit range to actual data: =COUNTIF(A1:A1000, criteria) 2. Convert data to Excel Table for dynamic ranges 3. Turn off automatic calculation temporarily 4. Use COUNTIFS for better performance with multiple criteria
Define specific ranges rather than entire columns. Use named ranges for clarity.
Example:
Best Practices and Advanced Tips
Enhance COUNTIF by combining it with other functions. Use SUM(COUNTIF(range, {criteria1, criteria2})) for OR logic counting. Combine with INDIRECT for dynamic range references: =COUNTIF(INDIRECT(A1), '>100') where A1 contains 'Sheet2!B:B'.
For large datasets exceeding 50,000 rows, use structured references with Excel Tables. Convert your range to a table (Ctrl+T) and use =COUNTIF(Table1[Sales], '>50000'). This improves calculation speed by up to 40% and automatically adjusts as data grows.
COUNTIF may fail to match seemingly identical text due to hidden characters. Always use CLEAN and TRIM functions on imported data: =COUNTIF(A:A, TRIM(CLEAN(B1))). This is especially important with data copied from web sources or other applications.
To count cells containing actual asterisks (*) or question marks (?), use a tilde (~) before them. For example, =COUNTIF(A:A, '~*') counts cells containing literal asterisks. This escape character is essential when working with data containing these symbols.
Always wrap COUNTIF in error handling for production spreadsheets: =IFERROR(COUNTIF(DataRange, Criteria), 0). This prevents #VALUE! errors from breaking dependent calculations and provides cleaner reports.
Need Help with COUNTIF Function Guide?
Stop struggling with formula syntax. Use AskFormulas to generate validated formulas instantly with our AI-powered tool.
Example Excel formula:
Related Formulas
Master COUNTIFS to count cells with multiple criteria. Learn syntax, see real examples, and solve errors for powerful multi-condition data analysis.

Master the SUMIF function with practical examples and error solutions. Learn how to sum cells based on criteria with step-by-step tutorials.

Master the AVERAGE function with practical examples and error solutions. Learn to calculate mean values and analyze data efficiently in Excel and Sheets.
