Sub topic 7
Using Cell Values in Criteria with the & Operator
This chapter assumes you can enter formulas in Google Sheets, read ranges such as A2:A100, and use COUNTIFS, SUMIFS, and AVERAGEIFS with a single text condition. It also assumes you have seen comparison operators such as >= inside criteria. Here you will learn how to build criteria from cell values so you can change a threshold or a category without editing the formula.
Why move criteria into cells
A formula such as =SUMIFS(E2:E100, D2:D100, ">10") works, but the number 10 is buried inside the formula. To test 20 instead, you must edit the formula. If the same formula appears in many cells, you must edit every copy.
If the threshold lives in a cell, you change it once and every formula that refers to it updates. This is the basis of a reusable summary table, which a later chapter builds.
There are two cases to handle:
- The criterion is only a value, such as the text
Westin cellG2. You pass the cell reference directly. - The criterion is an operator plus a value, such as
>10. You must join the operator and the cell value into one text string with the&operator.
Passing a cell reference as the whole criterion
When the cell holds the entire condition, give the reference as the criterion argument:
=COUNTIFS(A2:A100, G2)If G2 contains West, this counts rows where the region equals West. If G2 contains the number 10, it counts rows equal to 10. If G2 contains the text >10, the function reads it as "greater than 10", because the criterion is parsed the same way whether it is typed in the formula or read from a cell.
That last point is useful. You can let a user type >10 or <=5 directly into a criteria cell and the formula will respect it. The downside is that users must know the syntax. Most of the time it is easier to store only the number and build the operator into the formula.
Joining an operator to a cell value with &
The & operator joins two pieces into one text string. Criteria are text strings that SUMIFS and its relatives interpret, so & is the standard way to combine an operator with a cell value:
=SUMIFS(E2:E100, D2:D100, ">"&H1)Suppose H1 contains 10. Then ">"&H1 becomes the text ">10", and the formula sums Revenue for rows where Units (column D) is greater than 10. Change H1 to 25 and the result updates at once.
The operator must be in quotation marks, because it is literal text. The cell reference must not be in quotation marks. Compare these two:
| Written as | What the function receives | Result |
|---|---|---|
| `">"&H1` | `>10` | Rows with a value above 10 |
| `">H1"` | `>H1` | Rows with a value greater than the text "H1", which matches nothing useful |
| `">" & "10"` | `>10` | Same as the first row |
All six comparison operators work this way: ">"&H1, "<"&H1, ">="&H1, "<="&H1, "<>"&H1, and "="&H1. The = form is rarely needed, because passing H1 alone already means "equal to".
Not equal to a cell value
To exclude one category, use "<>"& with the cell:
=COUNTIFS(A2:A100, "<>"&G2)If G2 holds West, this counts every row whose region is not West. Be aware that blank cells in the range also count, because an empty cell is not equal to West. If you need to exclude blanks as well, add a second pair such as A2:A100, "<>".
Combining several cell-driven criteria
Each criteria pair can use its own cell. The pairs still combine with AND, as in earlier chapters:
=AVERAGEIFS(E2:E100, A2:A100, G2, D2:D100, ">="&H1)This averages Revenue for rows where Region equals the value in G2 and Units is at least the value in H1. Here G2 is passed directly because it holds a plain value, and H1 is joined to ">=" because it holds only a number.
Using the same cell twice for a range
A range condition needs two pairs on the same column, one for each end. Each end can come from its own cell:
=COUNTIFS(A2:A100, "West", C2:C100, ">="&J1, C2:C100, "<"&J2)J1 is the lower bound and J2 is the exclusive upper bound. This pattern works for numbers and for dates. Dates are covered in more detail in a later chapter, but the key point applies here: a date in a cell is a number underneath, so ">="&J1 works when J1 holds a real date value.
Building criteria from text and functions
Because & produces ordinary text, you can place any expression on its right side. Common examples:
">"&AVERAGE(D2:D100)selects rows above the average of the column.">="&TODAY()-30selects rows from the last 30 days.">="&DATE(2026,1,1)selects rows on or after a fixed date.
=SUMIFS(E2:E100, D2:D100, ">"&AVERAGE(D2:D100))This sums Revenue for rows where Units exceeds the column average. The average is calculated first, then joined to >, then used as the criterion.
Joining text for wildcards
The & operator also lets you add wildcards around a cell value. A wildcard is a character that stands for other characters: * for any number of characters and ? for exactly one.
=COUNTIFS(B2:B100, G3&"*")If G3 holds Wid, the criterion becomes Wid*, so the formula counts products whose names start with Wid. Use "*"&G3&"*" to match the text anywhere in the cell.
Common errors
Most problems with cell-driven criteria come from a few causes.
- Quoting the cell reference.
">H1"is treated as text, not as a reference. Move the reference outside the quotes:">"&H1. - Missing
&. Writing">" H1produces a formula parse error. The two pieces must be joined. - Dates stored as text. If
J1holds the text2026-01-01instead of a real date,">="&J1may not match any date cells. Check that the cell is right-aligned by default, or test it with=ISNUMBER(J1). - Hidden spaces. A criteria cell containing
Westwith a trailing space will not matchWest. UseTRIMon the source cell or retype it. - Wrong reference type when filling down. If a threshold cell should stay fixed, write
$H$1. A plainH1will shift as you fill the formula down and point at empty cells, so the criterion becomes>with nothing after it.
A worked example
The sheet below has Region in column A, Product in B, Date in C, Units in D, and Revenue in E. Two input cells hold the settings: G2 is the region and H1 is the minimum number of units.
G2: West
H1: 10
Rows: =COUNTIFS($A$2:$A$100, $G$2, $D$2:$D$100, ">="&$H$1)
Total: =SUMIFS($E$2:$E$100, $A$2:$A$100, $G$2, $D$2:$D$100, ">="&$H$1)
Mean: =IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, $G$2, $D$2:$D$100, ">="&$H$1), "No matches")Change G2 to East or H1 to 25, and all three results recalculate. The absolute references ($A$2:$A$100) keep the ranges fixed if you copy the formulas. The IFERROR wrapper shows "No matches" instead of #DIV/0! when no row qualifies.
Exercise
Column D holds Units and column E holds Revenue in rows 2 to 100. Cell H1 holds a minimum unit count and cell G2 holds a region name. Write a formula that sums Revenue for rows in the region named in G2 where Units is strictly less than the value in H1. Then explain why "<H1" would not work.
Show answer
=SUMIFS($E$2:$E$100, $A$2:$A$100, $G$2, $D$2:$D$100, "<"&$H$1). The text "<H1" is a single string, so the function compares each Units value with the literal text "H1" instead of the number stored in cell H1. The reference must sit outside the quotation marks and be joined with &.
Exercise
Cell J1 holds the date 2026-03-01 and cell J2 holds 2026-04-01. Write a COUNTIFS formula that counts rows in C2:C100 dated from J1 up to, but not including, J2.
Show answer
=COUNTIFS(C2:C100, ">="&J1, C2:C100, "<"&J2). The same date column appears in two criteria pairs, one for the inclusive start and one for the exclusive end.