Microsoft Office

Microsoft Excel Conditional Formatting If Statement

To use an IF statement in Excel conditional formatting, create a formula rule that returns TRUE when a cell should be highlighted. You can use =IF(B2>80,TRUE,FALSE), but =B2>80 gives the same result more simply. Select the cells, create the rule, and choose the formatting Excel.

Which licences fit your PC setup?

Prices are an AUD snapshot, not a live quote. Confirm variant and total on the listing.



How IF works in conditional formatting

The IF function has three arguments: =IF(logical_test,value_if_true,value_if_false). In a worksheet cell, it can return a label, number or calculation. In a conditional formatting rule, use a logical result to control whether the chosen format applies.

For example, =IF(B2>80,TRUE,FALSE) tests whether B2 exceeds 80. The shorter formula =B2>80 already returns TRUE or FALSE, so IF adds no benefit here. Neither formula changes the value stored in B2.

A formula such as =IF(B2>80,"Green","Red") does not assign colours. Choose a fill colour in the rule's formatting settings. To apply different colours to different outcomes, create separate rules.

Microsoft's conditional formatting guidance explains how logical formulas control formatting and where to enter them.

Create a rule to highlight scores above 80

Suppose student names are in A2:A5 and their scores are in B2:B5. Use the source example's scores: 85, 75, 90 and 78. These are whole-number scores out of 100.

  1. Select B2:B5, starting with B2 as the active cell.
  2. On the Home tab, select Conditional Formatting, then New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. Enter =B2>80 in the formula field. To use IF explicitly, enter =IF(B2>80,TRUE,FALSE) instead.
  5. Select Format, choose a fill colour or another visible format, then confirm the format and rule with OK.

The cells containing 85 and 90 should be highlighted. The cells containing 75 and 78 should retain their existing appearance unless another rule applies.

The comparison >80 excludes exactly 80. Use >=80 if a score of 80 should qualify. If the cells contain actual percentages, such as 85%, compare with 80% using =B2>80%. A percentage value of 85% is stored as 0.85, so comparing it with 80 would give the wrong result.

For a single threshold, Home > Conditional Formatting > Highlight Cells Rules > Greater Than is a simpler alternative. Formula rules become useful when the test involves another cell or several conditions.

Highlight an entire row using one cell

To highlight both a student's name and score, select A2:B5 and create a formula rule using =$B2>80. The dollar sign fixes column B, while the row number changes for each row being evaluated.

For row 2, both selected cells test B2. For row 3, both test B3. Without the fixed column, Excel would shift the reference sideways as it evaluates cells across the selected range.

Choose references to match the intended behaviour:

  • B2: both the column and row can adjust.
  • $B2: the column stays fixed while the row adjusts; useful for highlighting rows.
  • $B$2: every evaluated cell checks the same cell.
  • B$2: the row stays fixed while the column adjusts.

Write the formula for the top-left cell of the selected range and select that cell first. If your data starts on row 5, a row-based rule should normally begin with a reference such as $B5.

Use several conditions without nested IF formulas

Require two tests with AND

Suppose column C records whether an assessment is complete. To highlight rows with a score above 80 and a status of Complete, select A2:C5 and use =AND($B2>80,$C2="Complete"). Both tests must be true.

Allow either test with OR

To flag a row when its score is below 50 or its status is Missing, use =OR($B2<50,$C2="Missing"). Either condition triggers the selected formatting. Put text comparisons in double quotation marks.

Use different thresholds for different rows

IF is useful when a condition determines which threshold to check. If column C contains assessment types, =IF($C2="Advanced",$B2>90,$B2>80) highlights an Advanced row only when its score exceeds 90, and other rows when their score exceeds 80. Both branches return logical results.

These examples use commas between function arguments. If your Excel regional settings require semicolons, replace the argument-separating commas with semicolons.

Check rules that highlight the wrong cells

Open Home > Conditional Formatting > Manage Rules and inspect the affected range before changing the formula.

  • Check Applies to. A rule intended for B2:B5 should not accidentally include the header or stop before the last score.
  • Check the starting row. A formula referencing B1 against a range beginning at B2 can test the wrong row.
  • Check the data type. Numbers stored as text can produce unexpected comparisons; convert them to numbers before relying on a numeric threshold.
  • Exclude blanks where necessary. For a below-50 rule, =AND(B2<>"",B2<50) prevents empty cells from being highlighted.
  • Inspect overlapping rules. Compatible formats can combine; conflicting formats follow rule priority. Use Stop If True when a matching rule should prevent lower-priority rules from applying.

To remove an unwanted rule, delete it in Manage Rules. Clear Rules from Selected Cells removes all conditional formatting rules from that selection, so use it only when that is the intended result.

Put the rule to work

For related Excel learning, browse the Microsoft Office guides. If you are also dealing with Office setup, separate articles cover Office activation using Command Prompt and finding an Office product key using Command Prompt.

Start with B2:B5 and =B2>80, then change one score from 75 to 85 to check that the highlight updates before applying the rule to your full dataset.

Other editions for separate workloads

Other editions for separate workloads; prices in AUD, confirm the total on the listing.

How to check this worked

  1. Open Settings, System, Activation and confirm the edition shown.
  2. Enter the key and run activation; expect a green tick within a minute.
  3. Reboot and re-check activation survives the restart.

FAQ

What else should you know before buying?

What do I need before starting?
Read the requirements and confirm the edition first; the steps assume the machine is compatible.
How do I know the licence is genuine?
Activate on Microsoft's servers and check Settings, System, Activation. A working activation is the test.
Is this a subscription?
Keys sold here are one-time lifetime licences. Microsoft 365 plans are billed by Microsoft instead.
What if the key fails?
Email hi@ms.codes with the order number and a screenshot. Replacement or refund applies within 30 days.

Check who prepared and reviewed this guide

Written by
MS.Codes editorial
Reviewed by
Support team

Last verified: (source review; see test status above).

Recent Post