ThisCalculator

Everyday

Mark Rows with Logical Tests in Excel

Updated · Standard formula, shown below

Average pace 5.00 min/km
Average speed
12.00 km/h
Result
Finish time
50 min
You entered
Distance
10 km
You entered

This guide explains how to mark or highlight rows in Excel based on logical tests, such as checking if a value exceeds a threshold or matches a condition. You will learn how to use formulas with conditional formatting and helper columns, and how to apply these techniques to real data. The methods work in current versions of Excel for Windows and Mac.

Formula

The core idea is to test a condition for each row and then format or flag the row based on the result. In a helper column, you might write a formula like =IF(A2>100,"Yes","No"). For conditional formatting, you use a formula that returns TRUE for rows you want to highlight, such as =$A2>100. The dollar sign locks the column so the formula applies across the row.

Variables: A2 is the cell being tested, 100 is your threshold (change it as needed), and the result is either TRUE (mark) or FALSE (no mark).

Worked Example

Suppose you have a list of sales amounts in column A (A2:A10) and you want to mark rows where the sale is greater than $500.

  1. Select the range A2:C10 (or just A2:A10 if you only want to highlight the amount).
  2. Go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format.
  3. Enter the formula =$A2>500 (note the row number matches the first selected row).
  4. Click Format, choose a fill color, and click OK.

All rows where the value in column A is greater than 500 will be highlighted. If you change a value, the formatting updates automatically.

When to Use a Helper Column vs. Conditional Formatting

A helper column (a separate column with a formula) is useful when you need to filter, sort, or further calculate based on the test result. For example, you can filter for “Yes” to see only marked rows. Conditional formatting is better when you want a visual highlight without altering your data, and you don’t need to filter on the result.

Use a helper column if:

  • You need to count or sum marked rows.
  • You want to filter or sort by the mark.
  • Your test involves multiple columns and you want to see the logic.

Use conditional formatting if:

  • You only need a visual cue.
  • You want to avoid adding extra columns to your sheet.
  • Your data is frequently updated and you want automatic highlighting.

How to Write Logical Tests for Rows

Logical tests in Excel use comparison operators: =, >, <, >=, <=, and <> (not equal). You can combine conditions with AND and OR. For example, to mark rows where sales are between 100 and 200, use =AND($A2>=100,$A2<=200). To mark rows where either column A or column B is greater than 50, use =OR($A2>50,$B2>50).

When using conditional formatting, the formula must be written relative to the active cell in the selected range. If you select A2:C10 with A2 active, the formula should reference row 2. Excel will adjust the row numbers for each row in the range.

Common Mistakes and How to Avoid Them

One frequent error is forgetting the dollar sign before the column letter. If you write =A2>500 and apply it to a range, the column reference will shift as the formatting moves across columns, causing incorrect highlights. Always use $A2 to lock the column when you want to test a specific column for the entire row.

Another mistake is using absolute row references like $A$2, which will test only cell A2 for every row, so only row 2 gets highlighted. Use mixed references: $A2 (column locked, row relative) or A$2 (row locked, column relative) depending on your goal.

Also, ensure the formula returns TRUE or FALSE. If you use a formula that returns a number, Excel treats zero as FALSE and any non-zero as TRUE, which may cause unexpected highlights.

Alternatives to Marking Rows

Besides conditional formatting and helper columns, you can use Excel’s Table feature with structured references, or use the FILTER function (in Excel 365) to display only rows that meet a condition. For example, =FILTER(A2:C10,A2:A10>500) returns all rows where column A is greater than 500. This is a dynamic array formula that spills results into adjacent cells.

You can also use the COUNTIF function to count marked rows without a helper column, or use the SUMIF function to sum values in marked rows.

Frequently Asked Questions

How do I highlight an entire row based on a cell value?

Select the entire row range (e.g., A2:C10), then create a conditional formatting rule with a formula that references the cell you want to test, using a mixed reference like $A2. The dollar sign locks the column, so the test always looks at column A for each row.

Can I use multiple conditions to mark rows?

Yes, use the AND or OR functions in your formula. For example, =AND($A2>100,$B2<50) marks rows where both conditions are true. You can also create multiple conditional formatting rules for different conditions.

Why is my conditional formatting not working?

Check that the formula is entered correctly and that the active cell is the first cell in the selected range. Also verify that the formula returns TRUE for at least one row. If you are using a formula with relative references, ensure the row number matches the first selected row.

How do I mark rows with text criteria, like “Completed”?

Use a formula like =$A2="Completed" in conditional formatting, or =IF($A2="Completed","Yes","No") in a helper column. Text comparisons are case-insensitive in Excel.

Can I mark rows based on a date range?

Yes, use date functions. For example, to mark rows where the date in column A is in the last 7 days, use =AND($A2>=TODAY()-7,$A2<=TODAY()). Ensure the cells contain real dates, not text.

What is the difference between a helper column and conditional formatting?

A helper column adds a formula to your sheet, which you can filter, sort, or use in other calculations. Conditional formatting only changes the appearance of cells, without modifying data. Choose based on whether you need to further process the marked rows.

Related

Formula used
in t | Finish time | min | 50 | 0
in d | Distance | km | 10 | 0
out pace | Average pace | min/km | t / d | 2
out speed | Average speed | km/h | d / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.