2025-10-18 23:34

Status: Child

Tags: Excel data types data formatting

Conditional Formatting in Excel

Overview

Conditional Formatting is a tool that allows you to apply formats to a cell or range of cells, and have that formatting change depending on the value of the cell or the value of a formula. For example, you can have a cell appear bold only when the value of the cell is greater than 100. It is used to easily spot trends and patterns using colors, bars, and icons.

Types of Conditional Formatting

1. Highlight Cell Rules

Highlight Cell Rules allow you to format cells based on specific criteria or conditions.

Example: Student Grade Data

Formula Used for Total:

Formula Used for Percentage:

Formula Used for Grade:

=IF(Percentage >= 33, "PASS", "FAIL")
NameM2M3TotalPercentageGrade
Aman582714548PASS
Suman727017759PASS
Aman798420368PASS
Anshika2262FAIL
Anmol817220167PASS
Bhashkar234515FAIL
Sukh616119264PASS
Sudeep226120FAIL

Conditional Formatting Rule:

  • Highlight cells where Grade = "PASS" with green fill
  • Highlight cells where Grade = "FAIL" with red fill

2. Conditional Formatting with Formulas

Conditional formatting can be applied using custom formulas to create more complex conditions.

Example: Highlighting Salary Values

Format if salary is equal to or greater than:

Method 1: Highlight Specific Values (≥ )

Conditional Formatting Formula for Value Highlighting:

=C2>=80000

Where C2 is the cell containing the yearly salary value.

Formula Used for TRUE/FALSE Column:

=C2>=80000
NameYearly SalaryCondition
Gary Miller80,000TRUE
James Willard39,627TRUE
Richard Elliot18,000TRUE
Robert Spear80,000TRUE
Roger Mun134,000FALSE
Paul Garza34,808TRUE
Robert Marquez134,468FALSE
Natalie Porter45,000TRUE
Kim West80,000TRUE
Stevie Bridge21,972TRUE
Andre Cooper81,000FALSE
Crystal Doyle185,000FALSE
Robert Musser80,000TRUE
Daniel Garrett140,000FALSE
Ann Withers100,000FALSE
Method 2: Highlight Entire Rows (≥ )

Conditional Formatting Formula for Row Highlighting:

=$C2>=80000

The $ symbol before the column letter makes it an absolute reference, ensuring the formula checks the same column (Yearly Salary) for each row.

Steps to Apply:

  1. Select the entire data range (e.g., A2:C16)
  2. Go to HomeConditional FormattingNew Rule
  3. Select “Use a formula to determine which cells to format”
  4. Enter the formula: =$C2>=80000
  5. Click Format and choose your desired formatting
  6. Click OK
NameYearly Salary
Gary Miller80,000
James Willard39,627
Richard Elliot18,000
Robert Spear80,000
Roger Mun134,000
Paul Garza34,808
Robert Marquez134,468
Natalie Porter45,000
Kim West80,000
Stevie Bridge21,972
Andre Cooper81,000
Crystal Doyle185,000
Robert Musser80,000
Daniel Garrett140,000
Ann Withers100,000

3. Top/Bottom Rules

Top/Bottom Rules allow you to highlight the highest or lowest values in a range.

How to Highlight Top 3 Values

Steps:

  1. Go to HomeConditional FormattingTop/Bottom RulesTop 10 Items
  2. Under “Format cells that rank in the top”, select Top 3
  3. Choose “With Custom Format” and select your desired color
  4. Click OK

Excel automatically applies the formula:

=LARGE($E$2:$E$9, 3)

This identifies the 3rd largest value in the range and highlights all values greater than or equal to it.

Example: Top 3 Total Scores

Formula Used for Total:

Formula Used for Percentage:

=Total/4

(Assuming maximum marks per subject is 100, total maximum = 400)

NameM2M3M4TotalPercentage
Aman58275520028%
Suman72706624327%
Aman79846026323%
Anshika22606691%
Anmol81728028128%
Bhashkar23368144%
Sukh61614123318%
Sudeep222633%

Top 3 values in Total column: 281, 263, 243

4. Data Bars

Data Bars provide a visual representation of values in cells, displaying horizontal bars proportional to the cell values.

No formula is required – Data Bars are applied directly through:

  1. Select the range (e.g., F2:F9 for Percentage column)
  2. Go to HomeConditional FormattingData Bars
  3. Choose a color scheme

How Data Bars Work:

  • Minimum value in range = smallest bar
  • Maximum value in range = largest bar
  • All other values are proportionally scaled

Formula for calculating bar length (internal to Excel):

Example: Data Bars Applied to Percentages

NameM2M3M4TotalPercentage
Aman58275520050
Suman72706624360.75
Aman79846026365.75
Anshika22909624
Anmol81728028170.25
Bhashkar23368120.25
Sukh61614123358.25
Sudeep2226315.75

5. Color Scales

Color Scales apply a gradient of colors to cells based on their values, making it easy to visualize the distribution of data.

No formula is required – Color Scales are applied directly through:

  1. Select the range (e.g., E2:E9 for Total column)
  2. Go to HomeConditional FormattingColor Scales
  3. Choose a color scheme (e.g., Green-Yellow-Red)

How Color Scales Work:

  • Lowest value → One color (e.g., Red)
  • Midpoint value → Middle color (e.g., Yellow)
  • Highest value → End color (e.g., Green)

Formula for color calculation (internal to Excel):

For a 3-color scale:

  • If : Interpolate between Color 1 and Color 2
  • If : Interpolate between Color 2 and Color 3

Example: Color Scale Applied to Total Scores

NameM2M3M4Total
Aman582755200
Suman727066243
Aman798460263
Anshika229096
Anmol817280281
Bhashkar233681
Sukh616141233
Sudeep22263

Color Distribution:

  • Lowest (63) → Red
  • Middle (~172) → Yellow
  • Highest (281) → Green

6. Date Occurring

Date-based conditional formatting allows you to highlight cells based on date criteria (e.g., today, yesterday, this week, last month).

Common Date Formulas for Conditional Formatting

Highlight Today’s Date:

=A2=TODAY()

Highlight Yesterday:

=A2=TODAY()-1

Highlight This Week:

=AND(A2>=TODAY()-WEEKDAY(TODAY(),2)+1, A2<=TODAY()-WEEKDAY(TODAY(),2)+7)

Highlight This Month:

=AND(MONTH(A2)=MONTH(TODAY()), YEAR(A2)=YEAR(TODAY()))

Highlight Last Month:

=AND(MONTH(A2)=MONTH(TODAY())-1, YEAR(A2)=YEAR(TODAY()))

Highlight Dates in the Past:

=A2<TODAY()

Highlight Dates in the Future:

=A2>TODAY()

Example: Date-Based Data

Formula Used for Total:

Conditional Formatting Applied: Highlight rows where Date = “1/May/25”

Formula:

=$A2=DATE(2025,5,1)
DateM1M2M3M4Total
1/May/2560582755200
1/May/2535727066243
1/May/2540798460263
7/May/252229096
9/May/2548817280281
10/May/2540233681
1/May/2570616141233
7/May/255722263

Common Conditional Formatting Formulas Reference

Comparison Formulas

ConditionFormulaDescription
Equal to=A1=100Highlights if value equals 100
Not equal to=A1<>100Highlights if value doesn’t equal 100
Greater than=A1>100Highlights if value is greater than 100
Less than=A1<100Highlights if value is less than 100
Greater than or equal=A1>=100Highlights if value is ≥ 100
Less than or equal=A1<=100Highlights if value is ≤ 100
Between=AND(A1>=50, A1<=100)Highlights if value is between 50 and 100

Text-Based Formulas

ConditionFormulaDescription
Contains text=ISNUMBER(SEARCH("text",A1))Highlights if cell contains “text”
Starts with=LEFT(A1,3)="ABC"Highlights if cell starts with “ABC”
Ends with=RIGHT(A1,3)="XYZ"Highlights if cell ends with “XYZ”
Blank cells=ISBLANK(A1)Highlights empty cells
Non-blank cells=NOT(ISBLANK(A1))Highlights non-empty cells

Advanced Formulas

ConditionFormulaDescription
Duplicate values=COUNTIF($A$2:$A$100,A2)>1Highlights duplicates in range
Unique values=COUNTIF($A$2:$A$100,A2)=1Highlights unique values
Above average=A1>AVERAGE($A$2:$A$100)Highlights values above average
Top N values=A1>=LARGE($A$2:$A$100,5)Highlights top 5 values
Bottom N values=A1<=SMALL($A$2:$A$100,5)Highlights bottom 5 values

Summary

Conditional Formatting is a powerful feature in Excel that enhances data visualization and analysis by:

  • Automatically highlighting important values using formulas
  • Making trends and patterns immediately visible
  • Creating visual indicators using colors, bars, and icons
  • Enabling quick identification of outliers and key data points
  • Supporting both simple rules and complex formula-based conditions

Key Formula Syntax Rules:

  • Use = to start all conditional formatting formulas
  • Use $ for absolute references when highlighting entire rows
  • Combine functions like AND(), OR(), IF() for complex conditions
  • Reference the first cell in your selection range, Excel will auto-adjust for other cells

By mastering these conditional formatting formulas, you can create more intuitive and informative spreadsheets that communicate data insights effectively.

References