Excel Practice Test

โ–ถ

What Is COUNTIF in Excel?

COUNTIF is one of the most useful functions in Excel โ€” it counts cells in a range that meet a single condition you define. Where a plain COUNT function simply tallies how many cells contain numbers, COUNTIF lets you ask a targeted question: how many cells in this range contain the word "Pending"? How many values in this column are greater than 1000? How many dates fall after a particular cutoff? COUNTIF answers all of these with a single formula, returning a number that updates automatically when your data changes.

The function belongs to a family of conditional aggregation functions in Excel that includes SUMIF (sum values that meet a condition), AVERAGEIF (average values that meet a condition), and COUNTIFS (count based on multiple conditions simultaneously). Among these, COUNTIF is typically the first one new Excel users encounter โ€” it's simple in structure, immediately practical, and it teaches the logic of criteria-based formulas that applies to the more advanced members of the family.

Understanding COUNTIF well pays dividends beyond the function itself. The criteria syntax you learn for COUNTIF โ€” how to write comparison operators like ">100", how to use wildcards like "*North*", how to reference cells as criteria โ€” transfers directly to SUMIF, AVERAGEIF, COUNTIFS, SUMIFS, and AVERAGEIFS. Mastering COUNTIF means you're already halfway to mastering the rest of the conditional aggregation family. If you're building out your broader Excel formulas knowledge, COUNTIF is the logical starting point for conditional logic.

This guide covers everything you need to use COUNTIF confidently: the full syntax explanation, worked examples across common use cases, the comparison with COUNTIFS for multi-criteria situations, and the most common mistakes โ€” with fixes for each.

  • Syntax: =COUNTIF(range, criteria)
  • What it returns: A whole number โ€” the count of cells in the range that match the criteria
  • Range: The cells you want to count from โ€” can be a single column, row, or block of cells
  • Criteria: The condition a cell must meet to be counted โ€” can be a number, text, cell reference, logical expression (like ">100"), or wildcard pattern (like "Mar*")
  • Case sensitivity: COUNTIF is NOT case-sensitive โ€” "apple", "Apple", and "APPLE" are all treated as identical
  • Blank cells: Use "" as criteria to count blanks; use "<>" to count non-blanks
  • Related functions: COUNTIFS (multiple conditions), SUMIF (sum instead of count), COUNTBLANK (count empty cells only)

How to Write a COUNTIF Formula

check

Click the cell where you want the count to appear. This can be anywhere on the sheet โ€” typically below or beside the data you're counting, or in a summary area. Type an equals sign (=) to start the formula, then type COUNTIF and an opening parenthesis.

rows

Select or type the range of cells you want to count from. For a column of data in A2 to A100, type A2:A100. For a block, type A2:C50. Press F4 after selecting the range if you plan to copy the formula โ€” this locks the reference with dollar signs (e.g., $A$2:$A$100) so it doesn't shift when copied.

settings

After the range, type a comma, then your criteria. Text criteria must be in double quotes: "Pending", "Yes", "London". Number criteria can be plain numbers: 42. Comparison operators must be inside quotes with the operator: ">100", "<>0", ">=500". Cell references don't need quotes โ€” just type the cell address or click it.

user

Type a closing parenthesis and press Enter. Excel returns the count immediately. If you see a #VALUE! error, check that your criteria text is properly quoted and your range is valid. If the result seems wrong, double-check that you're searching the right range and that the criteria matches the exact text or number format used in the data.

COUNTIF Syntax Explained in Detail

The full syntax for COUNTIF is: =COUNTIF(range, criteria). Both arguments are required โ€” COUNTIF with only one argument returns an error. Understanding each argument in depth helps you use the function correctly across the many different situations you'll encounter.

The range argument is the group of cells you want to count from. This can be a single column (A:A for the entire column A, or A2:A100 for rows 2-100), a single row (1:1 or A1:Z1), or a rectangular block of cells (A2:C50). COUNTIF does not support non-contiguous ranges โ€” you can't use comma-separated ranges like A2:A100,C2:C100 the way some other functions allow. If you need to count across multiple non-contiguous ranges, you sum two separate COUNTIF formulas: =COUNTIF(A2:A100,criteria)+COUNTIF(C2:C100,criteria).

The criteria argument defines what you're counting for. This is the argument where most of COUNTIF's flexibility lives. Here are the main forms it can take: a literal text string in double quotes ("Complete"), a literal number without quotes (42), a comparison expression in quotes (">500", "<>0", ">=100"), a wildcard pattern in quotes ("*Smith", "Jan*", "*budget*"), a date in quotes formatted as text ("1/15/2026"), or a cell reference (D2) pointing to a cell that contains the value or text you want to match.

When using cell references as criteria, you can also combine them with comparison operators using the ampersand (&) concatenation operator. To count values greater than the value in cell D2, write ">"&D2 as the criteria argument โ€” the operator is in quotes, then the & joins it to the cell reference.

This technique makes COUNTIF dynamic: when D2 changes, the count updates automatically without editing the formula. A solid working knowledge of these patterns makes COUNTIF a much more powerful tool than it first appears, and the same patterns apply across the conditional formatting rules and other criteria-based features in Excel.

COUNTIF Use Cases

๐Ÿ”ด Count by Exact Text Match

Count how many cells contain a specific word or phrase. Example: =COUNTIF(B2:B200,"Approved") counts all cells in B2:B200 that contain exactly the text Approved. COUNTIF is not case-sensitive, so Approved, APPROVED, and approved are all counted. Make sure the criteria text matches exactly what appears in your data โ€” trailing spaces in cells are a common cause of unexpected zero counts.

๐ŸŸ  Count with Comparison Operators

Count numeric values that meet a threshold. Example: =COUNTIF(C2:C500,">1000") counts all cells in C2:C500 with values greater than 1000. Supported operators: > (greater than), < (less than), >= (greater than or equal), <= (less than or equal), <> (not equal to). For "not equal to text": =COUNTIF(A2:A100,"<>Cancelled") counts everything except Cancelled.

๐ŸŸก Count with Wildcards

Use * (any sequence of characters) and ? (any single character) to count partial matches. =COUNTIF(A2:A100,"*North*") counts any cell containing the word North anywhere in the text. =COUNTIF(A2:A100,"Jan*") counts cells starting with Jan. =COUNTIF(A2:A100,"???-Code") counts cells where any 3 characters are followed by -Code. Wildcards only work with text values, not numbers or dates.

๐ŸŸข Count Blanks and Non-Blanks

Count empty or populated cells in a range. =COUNTIF(A2:A100,"") counts blank cells (cells with no content). =COUNTIF(A2:A100,"<>""") counts non-blank cells. Note: COUNTBLANK(A2:A100) is a simpler alternative for counting blanks. Cells containing spaces or zero-length strings may behave unexpectedly โ€” use TRIM and LEN checks if blank detection seems incorrect.

COUNTIF Formula Examples

๐Ÿ“‹ Text Examples

Common COUNTIF formulas for counting text values in your data.

  • Exact match: =COUNTIF(A2:A100,"London") โ€” counts cells containing exactly London
  • Not equal to: =COUNTIF(A2:A100,"<>Cancelled") โ€” counts everything except Cancelled
  • Starts with: =COUNTIF(A2:A100,"Mar*") โ€” counts cells starting with Mar (March, Marketing, Mario, etc.)
  • Contains word: =COUNTIF(A2:A100,"*pending*") โ€” counts cells containing the word pending anywhere
  • Ends with: =COUNTIF(A2:A100,"*Ltd") โ€” counts cells ending with Ltd
  • From cell reference: =COUNTIF(A2:A100,D1) โ€” counts cells matching whatever text is in cell D1; update D1 to change the search term
  • Count blanks: =COUNTIF(A2:A100,"") โ€” counts empty cells

๐Ÿ“‹ Number Examples

COUNTIF formulas for counting numbers that meet specific thresholds or conditions.

  • Exact number: =COUNTIF(B2:B100,0) โ€” counts cells containing exactly zero
  • Greater than: =COUNTIF(B2:B100,">1000") โ€” counts values above 1000
  • Less than or equal: =COUNTIF(B2:B100,"<=500") โ€” counts values 500 and below
  • Not zero: =COUNTIF(B2:B100,"<>0") โ€” counts all non-zero values
  • Dynamic threshold: =COUNTIF(B2:B100,">"&C1) โ€” counts values greater than whatever is in cell C1; change C1 to update the threshold automatically
  • Between two numbers: Use two COUNTIFs: =COUNTIF(B2:B100,">100")-COUNTIF(B2:B100,">500") counts values between 100 and 500

๐Ÿ“‹ Date Examples

COUNTIF formulas for counting dates โ€” including before, after, and relative to today.

  • Specific date: =COUNTIF(C2:C100,"1/15/2026") โ€” counts cells with that exact date (use the date format matching your regional settings)
  • After a date: =COUNTIF(C2:C100,">"&DATE(2026,1,1)) โ€” counts dates after January 1, 2026
  • Before today: =COUNTIF(C2:C100,"<"&TODAY()) โ€” counts past dates; updates dynamically every day
  • This year: Combine two COUNTIFs: =COUNTIF(C2:C100,">="&DATE(2026,1,1))-COUNTIF(C2:C100,">="&DATE(2027,1,1)) โ€” counts dates in 2026
  • From a cell: =COUNTIF(C2:C100,">"&D1) โ€” counts dates after the date in D1; change D1 to adjust the filter

COUNTIF vs COUNTIFS: Choosing the Right Function

COUNTIF accepts only one criteria range and one criterion โ€” that's its core limitation. When you need to count based on two or more conditions simultaneously, you need COUNTIFS. The syntax for COUNTIFS extends the COUNTIF pattern by accepting pairs of range-criteria arguments: =COUNTIFS(range1, criteria1, range2, criteria2, ...). You can add as many range-criteria pairs as your condition requires, up to 127 pairs.

To illustrate the difference: if you have a sales table with a Region column (A) and a Status column (B), and you want to count rows where Region is "North" AND Status is "Complete", COUNTIF can't do it โ€” it can only check one column.

COUNTIFS handles it cleanly: =COUNTIFS(A2:A100,"North",B2:B100,"Complete"). All conditions in COUNTIFS use AND logic โ€” every condition must be true for a row to be counted. If you need OR logic (count where Region is North OR Status is Complete), the correct approach is to sum two separate COUNTIF or COUNTIFS formulas, being careful to avoid double-counting rows that match both conditions.

A common pattern is combining COUNTIFS with date criteria to count activity in a specific period โ€” for example, counting orders placed in Q1 of 2026 with a status of Shipped: =COUNTIFS(C2:C100,">="&DATE(2026,1,1),C2:C100,"<"&DATE(2026,4,1),B2:B100,"Shipped"). This kind of multi-criteria counting is where COUNTIFS genuinely shines, and it's one of the most frequently used patterns in financial and operational reporting spreadsheets. You'll find similar criteria logic used in Excel pivot tables when filtering by multiple dimensions โ€” understanding COUNTIFS deepens your intuition for how Excel handles conditional filtering generally.

Both COUNTIF and COUNTIFS have an important limitation: they don't support non-contiguous ranges within a single criteria pair. Each criteria range in a COUNTIFS must be a single, contiguous block, and all criteria ranges must be the same size as each other. If your data is structured in multiple separate blocks, you'll need to either restructure the data or use a helper column to combine the criteria into a single range before applying COUNTIFS. For more complex conditional aggregation across irregular data structures, Excel's array formulas with SUMPRODUCT offer an alternative that's more flexible, if more complex to write.

COUNTIF Troubleshooting Checklist

Text criteria is in double quotes โ€” forgetting quotes around text or expressions like >100 causes a #VALUE! or #NAME? error; numbers used as numeric criteria don't need quotes but comparison operators always do
The criteria matches the exact text in the cells โ€” trailing spaces, extra characters, or different number formats (e.g., 42 vs 42.0) prevent matches; use TRIM on your data or in the criteria if unexpected mismatches occur
Wildcards (* and ?) are only used with text values โ€” they don't work with numbers or dates; if you're searching for numbers with a pattern, convert the column to text first using TEXT() or format the criteria differently
The criteria range and the data you're checking match in size if combining multiple COUNTIF/COUNTIFS โ€” mismatched range sizes in COUNTIFS return a #VALUE! error
You're counting from the correct range โ€” a very common mistake is selecting a header row as part of the range, causing the header text to accidentally be counted if it matches the criteria
For dates, use DATE() function in the criteria rather than typed date text โ€” date formats vary by regional settings and typed date strings can fail to match stored date values; DATE(2026,3,15) is safer than "3/15/2026"
Results of 0 when you expect a positive count โ€” double-check for hidden characters in data cells by selecting one and looking at the formula bar; use LEN() to verify the actual length of the cell content matches your expectation

COUNTIF vs SUMIF: When to Use Each

Pros

  • Use COUNTIF when you want to know HOW MANY rows or cells meet a condition โ€” the result is always a whole number representing a count of records
  • COUNTIF is simpler to write and easier to explain to colleagues who aren't Excel-fluent โ€” the formula reads almost like plain English: count if this range contains this value
  • COUNTIF is the right tool for data validation: checking for duplicates (COUNTIF of the same range with a cell reference as criteria), verifying required fields are filled, or confirming that certain values appear the expected number of times
  • Use SUMIF when you want to TOTAL a numeric value for rows matching a condition โ€” SUMIF requires a third argument (the sum range) pointing to the column containing the values to add up
  • For dashboards and summary tables, COUNTIF is often used alongside SUMIF โ€” count shows volume, sum shows value โ€” giving a complete picture of how many transactions and what total amount they represent

Cons

  • COUNTIF can't handle multiple conditions โ€” you need COUNTIFS (the plural form) any time you need to apply two or more criteria simultaneously to the same count
  • COUNTIF doesn't distinguish between numbers stored as text and actual numbers โ€” if your data has inconsistencies in how values are stored, counts can be unexpectedly low or high
  • Neither COUNTIF nor SUMIF can count or sum based on background colour, font colour, or cell formatting โ€” those operations require VBA or helper columns with visible formatting indicators
  • COUNTIF doesn't sum values โ€” use SUMIF or SUMIFS when you need to aggregate amounts rather than count occurrences; mixing the two functions up is a common beginner mistake that produces nonsensical results

Common COUNTIF Mistakes and How to Fix Them

Even experienced Excel users run into predictable pitfalls with COUNTIF. Knowing the most common mistakes โ€” and their fixes โ€” saves significant debugging time when a formula produces unexpected results.

The most frequent mistake is forgetting quotes around text criteria or comparison operators. COUNTIF requires that any text string or expression using a comparison operator (>, <, >=, <=, <>) be enclosed in double quotes. Writing =COUNTIF(A2:A100,>100) returns a #VALUE! error; writing =COUNTIF(A2:A100,">100") works correctly. Numbers used as exact match criteria don't need quotes โ€” =COUNTIF(A2:A100,42) is fine โ€” but the moment you add an operator, quotes are required.

The second most common problem is criteria that doesn't match the data. COUNTIF returns zero when your criteria text doesn't exactly match the cell content, even if it looks identical on screen. Hidden trailing spaces are a frequent culprit โ€” if someone entered "Complete " (with a trailing space) instead of "Complete", your COUNTIF for "Complete" returns zero for those cells. Fix this by running TRIM on the data range, or use a wildcard: "Complete*" will match Complete, Complete_, and Complete with trailing spaces.

Date matching is another area where COUNTIF behaves unexpectedly. Excel stores dates as serial numbers (integers), and if you type a date in the criteria as a text string โ€” "1/15/2026" โ€” it may not match the stored serial number in the cells. The reliable approach is to construct date criteria using the DATE function combined with the & operator: ">="&DATE(2026,1,15). This generates the correct serial number for comparison regardless of your regional date format settings.

Finally, many users don't realise that COUNTIF is not case-sensitive by default โ€” "apple", "APPLE", and "Apple" all count the same. If you need case-sensitive counting, you have to use an array formula workaround with EXACT: =SUMPRODUCT((EXACT(A2:A100,"APPLE"))*1) counts only cells with exactly the casing "APPLE". This is rarely needed in practice, but it's good to know the limitation exists. Just as XLOOKUP and VLOOKUP treat lookup values case-insensitively, so does COUNTIF โ€” all of Excel's standard lookup and matching functions share this characteristic.

Practice Microsoft Excel MOS Exam Questions

Excel COUNTIF: Key Facts

2 args
COUNTIF takes exactly two arguments โ€” range and criteria. Both are required; omitting either causes an error.
127
Maximum number of range-criteria pairs COUNTIFS supports โ€” effectively unlimited for practical use cases
Not case-sensitive
COUNTIF treats text matches as case-insensitive โ€” 'apple', 'APPLE', and 'Apple' all count the same
2 wildcards
COUNTIF supports two wildcard characters: * (any sequence of characters) and ? (any single character) โ€” text only, not numbers
=0 or >0
Common pattern: COUNTIF>0 in an IF formula to check whether a value exists in a list โ€” a fast duplicate detector
COUNTIFS
The plural form โ€” COUNTIFS โ€” extends COUNTIF to handle multiple simultaneous conditions using AND logic

Advanced COUNTIF Techniques

Once you're comfortable with basic COUNTIF syntax, several advanced techniques extend the function's usefulness significantly. These patterns appear regularly in professional Excel work and are worth adding to your toolkit.

Using COUNTIF to detect duplicates is one of the most practically valuable applications. The formula =COUNTIF($A$2:$A$100,A2) placed in a helper column next to your data tells you how many times the value in each row appears in the entire list. Any row with a count greater than 1 is a duplicate entry.

This pattern is faster than conditional formatting for large datasets and gives you a sortable number you can filter on โ€” sort by the helper column descending to instantly surface the most duplicated values. You can also use this technique to find items in one list that appear in a second list: =COUNTIF(ListB,A2) returns a positive number if A2 exists in ListB and zero if it doesn't, functioning as a lookup existence check without needing VLOOKUP or XLOOKUP.

Dynamic criteria using cell references make COUNTIF formulas interactive. Instead of hard-coding the criteria in the formula, point the criteria argument to a cell that contains the value you want to match. Then create a dropdown list in that cell using Excel's Data Validation feature โ€” suddenly your COUNTIF summary updates instantly when a user selects a different option from the dropdown. This pattern is the foundation of simple interactive dashboards where a single dropdown selection filters and recalculates multiple summary metrics simultaneously, without requiring any macros or complex programming.

Combining COUNTIF with SUMPRODUCT enables COUNTIF-style counting with case sensitivity or with OR conditions across multiple columns. =SUMPRODUCT((A2:A100="North")+(B2:B100="North")>0) counts rows where either column A or column B contains "North" โ€” genuine OR logic that a single COUNTIF or COUNTIFS can't produce. SUMPRODUCT evaluates the logical arrays and sums the results, giving you the flexibility of COUNTIF with the structural flexibility of array formulas. For very large datasets (hundreds of thousands of rows), SUMPRODUCT can be slower than COUNTIFS, so use COUNTIFS with carefully designed OR decomposition for performance-critical situations.

COUNTIF also integrates naturally with named ranges, making formulas easier to read and maintain. Instead of =COUNTIF($A$2:$A$100,"Complete"), define a named range called StatusColumn for A2:A100, and write =COUNTIF(StatusColumn,"Complete"). When your data expands or the column moves, updating the named range definition automatically updates every formula that references it. Named ranges combined with structured Excel spreadsheet table design โ€” using Excel Tables (Ctrl+T) with automatic column references โ€” are the approach professional analysts use to make COUNTIF formulas that stay correct as data grows and changes over time.

Getting Started With COUNTIF: A Practical Approach

The fastest way to learn COUNTIF is to apply it to a dataset you're actually working with, rather than practising on abstract examples. Take any list you work with regularly โ€” a project status log, a customer list, an inventory table, an expense tracker โ€” and start by writing a COUNTIF that counts how many times each distinct value appears in one of the key columns. Even a simple count of how many items are "Complete" versus "In Progress" versus "Pending" immediately makes the function tangible and useful.

Once you've built your first working COUNTIF, push it slightly further: make the criteria dynamic by pointing it at a cell instead of hard-coding the text. Select a nearby cell, type a value that exists in your data, and update your COUNTIF formula to reference that cell as the criteria. Watch the count change when you type a different value. This single step โ€” moving from static to dynamic criteria โ€” is the conceptual breakthrough that unlocks COUNTIF's value for real-world reporting.

The next natural progression is COUNTIFS. Once you have a COUNTIF working, add a second condition: count the same thing, but only for a specific region, date range, or category. The syntax extension from COUNTIF to COUNTIFS is minimal โ€” you just add another comma-separated range-criteria pair โ€” but the analytical power increases significantly. Most professional Excel work that involves conditional counting uses COUNTIFS rather than COUNTIF, precisely because real business questions almost always involve more than one filter.

Treat any COUNTIF result of zero that you didn't expect as a learning opportunity rather than a bug to ignore. Investigate why: check the data for trailing spaces, verify the number format, confirm you're looking at the right range. Each investigation teaches you something about how Excel stores and compares data that makes you a more effective spreadsheet analyst.

The debugging skills you develop with COUNTIF transfer to every other function you use, because the underlying data-matching logic is consistent across Excel's entire function library. That transferability is one of the reasons COUNTIF is such a valuable function to truly master early in your Excel learning journey.

If you're working in a shared Excel environment โ€” where colleagues also edit the same workbooks โ€” it's worth formatting your COUNTIF ranges as official Excel Tables (Ctrl+T). Table references like =COUNTIF(Table1[Status],"Complete") automatically expand as new rows are added, eliminating the brittle fixed-range problem that causes COUNTIF formulas to silently miss newly added data. Consistently adopting this habit alone prevents a significant and recurring category of reporting errors in collaborative Excel files used by multiple people.

Take the Excel Practice Test

Excel COUNTIF Questions and Answers

What is the COUNTIF function in Excel?

COUNTIF counts the number of cells in a range that meet a single condition you define. The syntax is =COUNTIF(range, criteria). Range is the group of cells to count from; criteria is the condition a cell must meet to be counted. Criteria can be exact text, a number, a comparison expression like ">100", a wildcard pattern like "*North*", or a cell reference. COUNTIF returns a whole number.

How do I use COUNTIF with multiple criteria?

For multiple criteria simultaneously, use COUNTIFS (the plural form). The syntax is =COUNTIFS(range1, criteria1, range2, criteria2) โ€” add as many range-criteria pairs as needed. COUNTIFS uses AND logic: all conditions must be true for a row to be counted. For OR logic, add two separate COUNTIF or COUNTIFS formulas together, taking care to subtract any overlap if the same rows could match both conditions.

Why is my COUNTIF returning 0 when it should return a number?

The most common causes are: criteria text doesn't exactly match the data (check for trailing spaces using TRIM or LEN); text is in quotes but the cells contain numbers (or vice versa); the range doesn't include all the rows you expect (verify the range boundaries); or date criteria is entered as a text string that doesn't match Excel's stored date serial numbers (use the DATE function instead). Use COUNTIF with a wildcard (*) to narrow down whether the data is matching at all.

Is COUNTIF case-sensitive?

No โ€” COUNTIF is not case-sensitive. "apple", "Apple", and "APPLE" all count the same. If you need case-sensitive counting, use an array formula with EXACT: =SUMPRODUCT((EXACT(A2:A100,"APPLE"))*1) counts only cells that match the exact casing of APPLE. This is a workaround rather than a native feature, as Excel's standard matching functions โ€” including COUNTIF, VLOOKUP, and MATCH โ€” are all case-insensitive by design.

Can I use COUNTIF to find duplicates?

Yes โ€” this is one of the most useful COUNTIF applications. Place =COUNTIF($A$2:$A$100,A2) in a helper column next to your data. This formula counts how many times each row's value appears in the entire list. Any row with a count greater than 1 is a duplicate. Lock the range with dollar signs ($A$2:$A$100) so it doesn't shift when you copy the formula down. Sort or filter by the helper column to surface all duplicates.

What is the difference between COUNTIF and SUMIF?

COUNTIF counts how many cells in a range meet a condition โ€” the result is a count of rows. SUMIF totals the numeric values in a sum range for rows where a separate condition is met โ€” the result is a sum of values. SUMIF takes a third argument: the range containing the values to add. Use COUNTIF for 'how many' questions; use SUMIF for 'how much total' questions. Both functions have plural counterparts โ€” COUNTIFS and SUMIFS โ€” that support multiple conditions.
โ–ถ Start Quiz