GrepBoard/Manuals
605 manuals ·

Highlight whole rows with a conditional formatting formula

·Tested on Claude Sonnet 5.5 · 2026-10·Test scope ↓·5 steps

Ask an AI for a rule that fills overdue open rows, tell it the columns and the range, and recount which rows the formula fills before you trust it.

Ask an AI for a conditional formatting formula that fills the whole row yellow when a task is overdue and still open, and a formula comes back at once. If you paste it in and nothing turns yellow, look first at whether the AI guessed your columns, not at the syntax. The test sheet is an invented task list (A1:F40, a header row and 39 data rows), and two ways of asking are compared.

[1] The first question says nothing about the sheet. In the sheet, Due is column D and Status is column E.

run/a.en.prompt.txt
In Excel I want to highlight the whole row yellow with conditional formatting when the due date has passed and the status is "Open". What formula should I put in the rule?

The start of the answer (run/a.en.1.out.txt, the first line and the formula line out of 18; the code-block marker lines are cut with …):

output
Assuming the due date is in column C (starting at row 2) and the status is in column D, use this rule formula:…=AND($C2<TODAY(), $D2="Open")…

The syntax is correct, but the model assumed Due is in column C and Status in D. Both runs said so and told the reader to change the letters. Paste the formula as it stands and this sheet gets 0 filled rows.

[2] The second question gives the columns, the range and the active cell, and asks for the formula alone.

run/c.en.prompt.txt
Give me the formula for an Excel conditional formatting rule. Row 1 is the header (A ID, B Task, C Team, D Due, E Status, F Priority) and the data runs from row 2 to row 40. Due is a date; Status is one of "Open", "In progress" or "Done".I want the whole row (columns A to F) filled yellow when the due date is before today and the status is "Open".The rule applies to A2:F40, and the active cell (top left) of that selection is A2. Give only the formula, as one line in a code block, ready to paste into the rule's formula box. Below it, explain in one sentence why each $ is where it is.

Telling the model the range and anchor cell follows the test in Claude's prompting best practices: if a colleague with no context would be confused by the prompt, the model will be too. A person given this prompt would have asked which column holds the due date.

console
$ claude -p --model claude-sonnet-5-5 --max-turns 1 --tools "" --setting-sources "" --strict-mcp-config < run/c.en.prompt.txt > run/c.en.1.out.txt
output
…=AND($D2<TODAY(),$E2="Open")…Each `$` sits before the column letter so the rule always reads Due (D) and Status (E) no matter which of columns A to F is being formatted, while the row number has no `$` so it shifts down with each row, relative to the active cell A2, and each row is judged on its own data.

[3] To count whether this formula really fills 14 rows, run/cf_sim_en.py takes the first = line from the answer file and evaluates it in every cell of the range. References without $ move one cell at a time, and the result is compared with the rows that should be filled according to the data. The part that does the calculation:

run/cf_sim_en.py
…    full, part = [], []    for r in range(r0, r1 + 1):        hits = []        for c in range(c0, c1 + 1):            dr, dc = r - r0, c - c0            def cell(ref, dr=dr, dc=dc):                mm = re.fullmatch(r"(\$?)([A-Za-z]+)(\$?)(\d+)", ref)                cc = col_num(mm[2]) + (0 if mm[1] else dc); rr = int(mm[4]) + (0 if mm[3] else dr)                if rr < 1 or cc < 1 or rr > len(sheet) or cc > len(sheet[rr - 1]): return BLANK                return cell_value(sheet[rr - 1][cc - 1])            try: hits.append(bool(Evaluator(tokens, cell, today).expr()))            except NotImplementedError as e: print(f"unsupported function: {e}"); sys.exit(2)        if all(hits): full.append(r)        elif any(hits): part.append(r)    painted = full + part    print(f"formula: ={formula.lstrip('=')}")    print(f"range: {area} (formula anchor cell {m[1]}{m[2]}) · today {today}")    print(f"rows that should be filled (counted from the data): {len(want)} {want}")    print(f"rows filled across all columns: {len(full)} {full}")    if part: print(f"rows filled in some columns only: {len(part)} {part}")    extra = [r for r in painted if r not in want]; miss = [r for r in want if r not in full]    print(f"filled but should not be: {len(extra)} {extra}")    print(f"should be filled but is not (whole row): {len(miss)} {miss}")    ok = not extra and not miss and not part    print("verdict: match" if ok else "verdict: mismatch"); sys.exit(0 if ok else 1)…
console
$ python run/cf_sim_en.py run/tasks.en.csv @run/c.en.1.out.txt A2:F40formula: =AND($D2<TODAY(),$E2="Open")range: A2:F40 (formula anchor cell A2) · today 2026-10-23rows that should be filled (counted from the data): 14 [2, 6, 8, 9, 10, 20, 24, 28, 29, 35, 36, 37, 38, 40]rows filled across all columns: 14 [2, 6, 8, 9, 10, 20, 24, 28, 29, 35, 36, 37, 38, 40]filled but should not be: 0 []should be filled but is not (whole row): 0 []verdict: match

In Excel itself, count the same rows with =COUNTIFS($D$2:$D$40,"<"&TODAY(),$E$2:$E$40,"Open") and compare the number with the yellow rows you get by filtering on fill color. The script in this post fixes today as 2026-10-23, while TODAY() in Excel is the day you open the file. On another day the rows to fill change (this table gets row 21 on 10-24, making 15), so replace TODAY() in the Excel formula with DATE(2026,10,23), or add a date such as 2026-10-24 to the end of the script command. Rows 2 and 40 (first and last), row 21 (due today) and row 11 (overdue but done) are boundary cases placed on purpose. run/make_data.py builds the whole table.

[4] To see whether the checker catches a wrong formula, five hand-made formulas (not model output) were run against it. 14 rows should be filled.

console
$ python run/cases.py enfull | part | extra | missed | formula @ range 14 |   0 |   0 |   0 | =AND($D2<TODAY(),$E2="Open") @ A2:F40  0 |  14 |   0 |  14 | =AND(D2<TODAY(),E2="Open") @ A2:F40 39 |   0 |  25 |   0 | =AND($D$2<TODAY(),$E$2="Open") @ A2:F40 15 |   0 |   1 |   0 | =AND($D2<=TODAY(),$E2="Open") @ A2:F40 14 |   0 |   8 |   8 | =AND($D2<TODAY(),$E2="Open") @ A1:F40

Without $, 14 rows are filled in some columns only. With $D$2 the first row's condition applies to every row. Create the rule with A1:F40 selected and the same formula shifts by one row: 8 rows are filled wrongly and 8 are missed.

[5] What went wrong, counted over the 12 runs (three prompts, two runs each in English and Korean):

  • Unknown columns get guessed. All 4 runs of a, which had no sheet layout, assumed C and D and mismatched on this sheet. The 4 runs of b (columns given) and the 4 of c (range and active cell given too) all matched, with $D2 and $E2. The AI putting the $ in the wrong place did not occur in these runs; the one-row shift came from where the selection started.
  • Blank due dates. All 8 answers to a and b (4 in English, 4 in Korean) warned that a blank due date counts as 0 and may be filled. The 4 answers to c, asked for a single formula line, did not mention it. With row 15's due date emptied (run/tasks.en.blank.csv) the warning held (script calculation):
console
$ python run/cases.py en blankfull | part | extra | missed | formula @ range 14 |   0 |   0 |   0 | =AND($D2<TODAY(),$E2="Open",$D2<>"") @ A2:F40 15 |   0 |   1 |   0 | =AND($D2<TODAY(),$E2="Open") @ A2:F40
  • Answer length. b came back with steps and notes; c came back with one formula and one sentence. Accuracy was the same, and c is easier to paste from.

Do not rely on this check if the due dates are stored as text rather than dates: the checker reads only date-formatted values as dates, so it can disagree with the real sheet. After creating the rule, open Conditional Formatting > Manage Rules and confirm the "Applies to" box reads =$A$2:$F$40.

#conditional-formatting#excel#formula#prompt