To count cells across multiple columns with one condition in Excel, use the SUMPRODUCT function with COUNTIF (e.g., =SUMPRODUCT(COUNTIF(A2:A10,C2:C10,"Apple"))), or use COUNTIFS with multiple range/criteria pairs if you need to count rows that meet conditions in different columns simultaneously. For counting the same value across several separate columns, SUMPRODUCT(COUNTIF(...)) is the most direct method.
Why COUNTIF Alone Can’t Handle Multiple Columns
The standard COUNTIF function takes exactly two arguments: a single range and a single criterion. For example, =COUNTIF(A2:A10,"Apple") counts how many times “Apple” appears in A2:A10. If you try to give it multiple ranges like =COUNTIF(A2:A10,C2:C10,"Apple"), Excel returns a #VALUE! error because the function simply isn’t built to accept more than one range. The same limitation applies to COUNTIFS when you want to count the same value across multiple columns—COUNTIFS is designed for AND logic across different columns, not for adding counts from separate ranges.
Using SUMPRODUCT with COUNTIF to Count Across Columns
The cleanest way to count occurrences of a single value across multiple, non-adjacent columns is to combine SUMPRODUCT with COUNTIF. The COUNTIF function returns an array of counts (one per range), and SUMPRODUCT adds them up.
Example: Suppose you have “Apple” in A2:A10, B2:B10, and C2:C10, and you want the total count across all three columns. With the data in those ranges, enter:
=SUMPRODUCT(COUNTIF(A2:A10,"Apple")+COUNTIF(B2:B10,"Apple")+COUNTIF(C2:C10,"Apple"))
This returns the total number of cells containing “Apple” across the three ranges. If A2:A10 has 3, B2:B10 has 2, and C2:C10 has 1, the result is 6.
A more compact version uses an array constant to hold the ranges:
=SUMPRODUCT(COUNTIF(INDIRECT({"A2:A10","B2:B10","C2:C10"}),"Apple"))
This works because INDIRECT converts the text range references into actual ranges, and COUNTIF evaluates each one, returning an array like {3;2;1}, which SUMPRODUCT sums to 6. Note that INDIRECT is volatile—it recalculates every time Excel recalculates—so for large workbooks, the explicit + version is faster.
Using COUNTIFS for AND Logic Across Columns
If your goal is to count rows that meet conditions in different columns (for example, count rows where column A says “Apple” AND column B says “Red”), use COUNTIFS. It accepts multiple range/criteria pairs and applies AND logic.
Example: With fruit in A2:A10 and color in B2:B10, to count rows where A is “Apple” and B is “Red”:
=COUNTIFS(A2:A10,"Apple",B2:B10,"Red")
This returns the number of rows that satisfy both conditions. If there are 4 such rows, the result is 4. COUNTIFS does not add counts from different columns; it counts rows where all criteria are true.
Using SUMPRODUCT with Boolean Logic for OR Conditions
If you need to count cells that meet any of several criteria across multiple columns (OR logic), SUMPRODUCT with boolean multiplication is a flexible alternative. For example, to count cells in A2:A10 that are either “Apple” or “Orange”:
=SUMPRODUCT((A2:A10="Apple")+(A2:A10="Orange"))
But if you want to count across multiple columns with OR logic, you can add the boolean arrays together:
=SUMPRODUCT((A2:A10="Apple")+(B2:B10="Apple")+(C2:C10="Apple"))
This counts every cell in the three ranges that equals “Apple”. Each TRUE in the arithmetic is treated as 1, so the sum is the total count. This method avoids COUNTIF entirely and is often easier to read when you have many ranges.
How to Choose the Right Function
Here’s a quick guide to picking the right approach for your scenario:
- Count one value across several separate columns: Use
=SUMPRODUCT(COUNTIF(range1,"value")+COUNTIF(range2,"value")+...)or theINDIRECTversion. - Count rows that meet conditions in different columns (AND): Use
=COUNTIFS(range1,criteria1,range2,criteria2,...). - Count cells meeting any of several criteria across columns (OR): Use
=SUMPRODUCT((range1=crit1)+(range2=crit2)+...). - Count with wildcards (e.g., starts with “Ap”): Use
COUNTIForCOUNTIFSwith wildcards like"Ap*"inside theSUMPRODUCT(COUNTIF(...))pattern.
Common Problems and Pitfalls
Mismatched range sizes: In COUNTIFS, all ranges must have the same number of rows and columns; otherwise you get a #VALUE! error. In SUMPRODUCT, the arrays must be the same size too, or you’ll get incorrect results or errors.
Case sensitivity: COUNTIF and COUNTIFS are not case-sensitive by default. If you need case-sensitive counting, use SUMPRODUCT with EXACT, like =SUMPRODUCT(--EXACT(A2:A10,"Apple")).
Blank cells: COUNTIF treats blanks as text when you use criteria like "" (empty string). To count truly blank cells, use COUNTBLANK or COUNTIF(range,"")—both work, but be aware that "" also counts cells with formulas that return an empty string.
Volatile INDIRECT: The INDIRECT approach recalculates every time any change is made, which can slow down large workbooks. Prefer the explicit + version unless you have a dynamic range that changes frequently.
Alternatives: PivotTables and Dynamic Arrays
If you’re working with a large dataset and need a more visual summary, a PivotTable is often easier than writing formulas. You can drag multiple columns into the Values area and count them, but PivotTables aggregate by row, not across columns, so they’re not a direct substitute for counting the same value across different columns.
In Excel 365, you can use the VSTACK function to combine ranges into a single vertical array, then apply COUNTIF to that array. For example, with data in A2:A10, B2:B10, and C2:C10:
=COUNTIF(VSTACK(A2:A10,B2:B10,C2:C10),"Apple")
This is the most elegant solution in Microsoft 365, but VSTACK requires Excel 365 or Excel 2024. In older versions, SUMPRODUCT(COUNTIF(...)) remains the standard method.
Frequently Asked Questions
Can I use COUNTIF with multiple criteria in the same column? Yes, use COUNTIFS with the same range multiple times, e.g., =COUNTIFS(A2:A10,"Apple",A2:A10,"Red")—but this counts rows where A is both “Apple” and “Red”, which is impossible unless the cell contains both. For OR within the same column, use =COUNTIF(A2:A10,"Apple")+COUNTIF(A2:A10,"Orange").
How do I count cells across multiple columns that are not adjacent? Use the SUMPRODUCT(COUNTIF(...)) method with each range listed separately, or use VSTACK in Excel 365. Non-adjacent ranges are fine as long as you list them individually.
Why does my COUNTIFS return 0 when I expect a positive number? Check that the criteria are entered correctly—text must be in quotes, and numbers don’t need quotes. Also ensure the ranges are the same size. If you’re using dates, make sure they’re real dates, not text.
Can I use wildcards with SUMPRODUCT(COUNTIF(…))? Yes, wildcards work inside the COUNTIF criteria, e.g., =SUMPRODUCT(COUNTIF(A2:A10,"Ap*")+COUNTIF(B2:B10,"Ap*")) counts all cells starting with “Ap” in both ranges.
Is there a way to count unique values across multiple columns? To count unique values across multiple columns, you can use SUMPRODUCT with COUNTIF and a denominator, but it’s tricky. A simpler approach in Excel 365 is to use COUNTA(UNIQUE(VSTACK(A2:A10,B2:B10,C2:C10))).
Does this work in Google Sheets? Yes, SUMPRODUCT and COUNTIF work the same in Google Sheets, but VSTACK is not available; use {A2:A10;B2:B10;C2:C10} with COUNTIF instead, e.g., =COUNTIF({A2:A10;B2:B10;C2:C10},"Apple").
Related
- T Minus Two Months: Meaning, Origin & Real Uses
- How to Improve Aim on Mouse: 12 Proven Steps
- Call of Duty on Mac: Can You Play It?
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel SUMIFS With OR Criteria: Formulas and ExamplesExcel’s SUMIFS function does not provide a built-in OR operator between criteria: to match one condition or another,…
- WORKDAY in Excel: Calculate Business Days and DatesUse Excel’s WORKDAY function to calculate a date a chosen number of working days before or after a…
- Excel MIN Ignore NA: Formulas That WorkYes. In Excel for Microsoft 365, use =AGGREGATE(5,6,A2:A10) to find the smallest numeric value in A2:A10 while ignoring…
- How to Add a New Line in Excel CONCATENATETo add a new line between text values joined with Excel’s CONCATENATE function, insert CHAR(10) between the cell…
- Extract the First Word in Excel With a FormulaTo extract the first word from text in Excel, put the source text in A2 and enter =LEFT(TRIM(A2),FIND("…
- Excel SUMIF Does Not Include? Hidden Gaps ExplainedExcel’s SUMIF function does not include cells that fail the criteria you specify, but more specifically, it does…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.