How to Format Cell Based on Formula in Excel (13 Useful Examples)

The following dataset represents the Devices of several Brands, Models, and Prices of those Devices. We will use it to demonstrate how to format cells based on its contents.

1.01-Excel format cell based on formula


How to Open a New Formatting Rule Window from Conditional Formatting Feature in Excel

  • Select the range B5:E22.
  • Go to the Home tab and the Styles group.
  • Choose Conditional Formatting and select New Rule.

1-Use Conditional formatting feature

  • A window named New Formatting Rule will pop up. Choose the Use a formula to determine which cells to format option for select a Rule Type.
  • In the field Format values where this formula is true, use a formula to format cells as you want.

2-Use a formula to determine which cells to format feature

Notes:

This procedure will be used to pop up the New Formatting Rule window in each of the examples below.


Method 1 – Using an Excel Formula to Format a Cell Depending on Another Cell

Let’s format the Sales cells based on various requirements.

Case 1 – Equal To $490.00

  • Select the range E5:E22.
  • Open the New Formatting Rule window.
  • In the Format values where this formula is true box, use the following formula:
=$E5=490
  • Pess Format.

3-Apply the formula in the edit the rule description option

  • The Format Cells dialog box will pop out. Under the Fill tab, select a color and press OK.

4-Selection of color from Fill tab

  • You’ll see the highlighted cells which are equal to E5.

5-Highlighting cells which are equal to $490.00

Case 2 – Not Equal To $490.00

  • Type the following formula in the New Rule and press Format:
=$D5<>490

6-Use formula in the New Formatting Rule window

  • The Format Cells dialog box will pop out. Under the Fill tab, select a color.
  • Press OK.

7-Selecting any color from the Fill tab

  • You’ll see the desired changes.

8-Formatting the cells which are not equal to $490.00

Case 3 – Greater Than $1,000.00

  • Use the following formula and press Format.
=$D5>1000

9-Applying formula to format cells

  • Select any color from the Fill tab and hit OK.

10-Choosing any color from the Fill tab

  • You’ll see the highlighted cells whose values are greater than $1,000.00.

11-Formatting the cells which are greater than $1,000.00

Case 4 – Greater Than or Equal To $1,000.00

  • Use the following formula:
=$D5>=1000
  • Press Format.

12-Using formula to format cells in Excel

  • Format the color as you want.

13-Selecting any color from the Fill tab

  • You’ll be able to highlight cells whose values are greater than or equal to $1,000.00.

14-Highlighting cells whose values are greater than or equal to $1,000.00

Case 5 – Less Than $700.00

  • Insert the following formula and select Format.
=$D5<700

15-Apply formula for formatting cells

  • Choose your formatting and press OK.

16-Select any color under the Fill tab

  • You’ll see the highlighted cells whose values are less than $700.00.

17-Formatting cells whose values are less than $700.00

Case 6 – Less Than or Equal To $700.00

  • Use the following formula and choose Format.
=$D5<=700

18-Use formula in the New Formatting Rule window

  • Choose your formatting and press OK.

19-Use the Fill tab to Select any color

  • You’ll see your desired highlighted cells.

20-Highlighting cells whose values are less than or equal to $700.00

Case 7 – Between $600.00 and $1,000.00

  • Use the following formula:
=AND($E5>600, $E5<1000)

21-Use AND function to format cells

  • Format the cells as you want them and press OK.

22-Selecting any color from the Fill tab

  • It’ll return the formatted cells.

23-Formatting those cells whose values are between $600.00 and $1,000.00

Read More: How to Do Conditional Formatting Based on Another Cell in Excel


Method 2 – Applying an Excel Formula to Format Rows with Text Criteria

In the below dataset, we’ll look for a product Notebook and format the rows where the product is present.

Case 1 – Using the SEARCH Function: Case-Insensitive

  • Select cell range C5 to C22.
  • Make a New Conditional Formatting rule and insert the following formula in Format values where this formula is true.
=SEARCH(“Notebook”,$C5)>0
  • Click on Format.

24-Use SEARCH function to format cells

  • Choose any color from the Fill tab and select OK.

25-Selecting any color from the Fill tab

  • The SEARCH function returns the formatted cells with the case-insensitive issue.

26-Formatted cells using the SEARCH function

Read More: How to Apply Conditional Formatting to Each Row Individually


Case 2 – Applying the FIND Function: Case Sensitive

  • Use the following formula in the Format values where this formula is true box.
=FIND(“Notebook”,$C5)>0
  • Select Format.

27-Apply the FIND function to highlight cells

  • Select a formatting color and press OK.

28-From the Fill tab Selects any color

  • You’ll see the highlighted cells containing only “Notebook” values, not “notebook”.

29-Output of the FIND function

Read More: How to Change Row Color Based on Text Value in Cell in Excel


Method 3 – Formatting Rows with Number Criteria Based on Formula

We’ll format the rows where the price of a Desktop or Notebook exceeds $800.00.

  • Use the following formula for a New Conditional Formatting Rule:
=$E5>800
  • Press Format.

30-Apply formula to format rows

  • Choose a fill color and press OK.

31-Select any color from the Fill tab

  • It’ll return the desired rows in the specified color.

32-Output of the formatting rows using formula


Method 4 – Formatting Odd Numbered Cells in Excel Based on Formula

  • Use the following formula in the Conditional Formatting rule box:
=ISODD(E5)

33-Use ISODD function in the New Formatting Rule window

  • Apply formatting as you want and click on OK.

34-Choose any color from the Fill tab

  • You’ll see the odd numbers in the selected color.

35-Output of the ISODD function


Method 5 – Using Excel Formula to Format Even Numbered Cells

  • Use the following formula in the Conditional Formatting Rule box:
=ISEVEN(E5)

36-Apply ISEVEN function to format even number cells

  • Apply formatting and press OK.

37-Selecting any color from the Fill tab

  • You’ll see the even numbers in the selected color.

38-Format cells using the ISEVEN function


Method 6 – Applying Excel Formula with the AND Function to Format Cells

We’ll highlight the rows which contain the product Desktop with the Price below $800.

  • Use the following Conditional Formatting formula:
=AND($C5="Desktop", $E5<800)
  • Select Format.

39-Apply AND function in the New Formatting Rule window

  • Choose a fill color and press OK.

40-From the Fill tab select any color

  • It’ll return the formatted rows.

41-Returns of the AND function


Metho 7 – Formatting Cells with the OR Function in Excel

  • Insert the following formula into the Conditional Formatting rule box:
=OR($C5="Desktop", $E5<800)
  • Press Format.

42-Type OR function in the Edit the rule description box

  • Choose a fill color and press OK.

43-Choosing any color from the Fill tab

  • The OR function will return the formatted rows.

44-Formatting cells using the OR function


Method 8 – Applying the ISBLANK Function to Format Blank Cells

  • Use the following formula inside the Conditional Formatting Rule box:
=ISBLANK(B5)
  • Press Format.

45-Insert ISBLANK function in the Edit the rule description box

  • Choose a fill color and press OK.

46-Select any color to format cells

  • The ISBLANK function will highlight the blank cells.

47-Output of the ISBLANK function


Method 9 – Formatting Non-Blank Cells Based on Excel Formula

  • Use the following formula into the Conditional Formatting rule box:
=NOT(ISBLANK(B5))

48-Write down the NOT and ISBLANK functions in the Edit the rule description box

  • Select any color to fill the cells and press OK.

49-Selecting any color from the Fill tab

  • You will format the non-blank cells.

50-Formatting non-blank cells


Method 10 – Formatting Duplicate Cells Based on Formula

Case 1 – Formatting Duplicate Cells Including First Occurrences

Let’s check for repeated brand names (column B):

  • Use the following formula in the Conditional Formatting rule box:
=COUNTIF($B$5:$B$22,$B5)>1

51-Apply COUNTIF function in the Edit the rule description box

  • Pick your preferred formatting and press OK.

52-Choosing any color from the Fill tab

  • This will return the duplicate information across rows including the first occurrences.

53-Formatting the duplicate cells including the first occurrences


Case 2 – Formatting Duplicate Cells Without First Occurrences

  • Use the following formula in the Conditional Formatting box:
=COUNTIF($B$5:$B5,$B5)>1
  • Now press Format.

54-Apply COUNTIF function to format cells

  • Go to Format and pick a fill color, then press OK.

55-Selecting any color from the Fill tab

  • This will return the highlighted rows without the first occurrences.

56-Format the duplicate cells without the first occurrences


Case 3 Formatting Consecutive Duplicate Cells in Excel

Let’s repeat the duplicate check for brand names but highlight only consecutive duplicates:

  • Use the following formula in the Conditional Formatting rule box:
=$B5=$B6
  • Press Format.

57-Apply the formula in the New Formatting Rule window

  • Choose your formatting and press OK.

58-From the Fill tab selects any color

  • Apply and you’ll get consecutive duplicate cells.

59-Formatting only consecutive cells or rows without the last


Method 11 – Using the Excel AVERAGE Function to Format Cells

Case 1 Formatting Cells Greater Than Average Value

We will format the rows in which the price of the products is greater than the average.

  • Insert the following formula into the Conditional Formatting rule box:
=$E5>AVERAGE($E$5:$E$22)

60-Type AVERAGE function in the Edit the rule description box

  • Choose your formatting in the Format box.

61-Selecting any color from the Fill tab

  • You’ll get the highlights.

62-Format the rows in which the price of the products is greater than the average


Case 2 – Formatting Cells with Lower Than the Average Value

  • Insert the following formula into the Conditional Formatting rule box:
=$E5<AVERAGE($E$5:$E$22)

63-Write down the AVERAGE function to format cells

  • Choose your preferred formatting in the Format option.

64-Choosing any color from the Fill tab

  • You’ll get the desired output.

65-Format the rows in which the price of the products is less than the average


Method 12 – Formatting Cells with Top 3 Values Based on Formula

We’ll use a function to format the rows with 3 top prices of the products.

  • Insert the following function into the Conditional Formatting rule box:
=$E5>=LARGE($E$5:$E$22,3)
  • Press Format.

66-Apply of large function to format cells

  • Choose a fill color and press OK.

67-Selecting any color from the Fill tab

  • This will return the expected output.

68-Use the LARGE function to format the rows with 3 top prices of the products


Method 13 – Formatting Entire Rows with Excel Formula When Any Cell Is Blank

  • Use the following formula in the Conditional Formatting rule box and press Format:
=COUNTBLANK($B5:$E5)

69-Use the COUNTBLANK function in the Edit the rule description box

  • Select any color to fill the cells and press OK.

70-Selecting any color from the Fill tab

  • This’ll return the dataset highlighting the rows which have blank cells.

71-Highlighting the rows which have blank cells

Read More: Conditional Formatting If Cell is Not Blank


Things to Remember

  • The formula you use must evaluate to either “TRUE” or “FALSE” for each cell in the range you want to format.
  • The formula can reference other cells or ranges in the workbook, but make sure you use the correct cell references.
  • When you create a new formatting rule, select the correct range of cells you want to format.
  • You can create multiple formatting rules for the same range of cells, but keep in mind that the rules will be applied in the order they are listed in the “Conditional Formatting Rules Manager” dialog box.
  • If you need to edit or delete a formatting rule, go to the “Conditional Formatting Rules Manager” dialog box, which can be accessed by clicking “Conditional Formatting” and then “Manage Rules” in the “Styles” group.
  • If you want to copy formatting from one range of cells to another, use the “Format Painter” tool in the “Clipboard” group of the “Home” tab.
  • Remember that conditional formatting is only applied to the cells in the current view of the worksheet. If you filter or sort the data, the formatting may change.

Frequently Asked Questions

Can I use multiple formulas for conditional formatting in the same range of cells?

Yes, you can use multiple formulas for conditional formatting. The rules will be applied in the order they are listed in the “Conditional Formatting Rules Manager” dialog box.

Can I use conditional formatting to apply different font styles or sizes?

Yes, you can use conditional formatting to apply different font styles or sizes. You can do this by selecting “Font” in the “Format Cells” dialog box instead of “Fill” or “Border“.

How do I remove conditional formatting from a range of cells?

To remove conditional formatting from a range of cells, select the cells, click on “Conditional Formatting” in the “Styles” group, and then select “Clear Rules” from the drop-down menu.


Download the Practice Workbook


Related Articles

<< Go Back to Conditional Formatting Formula | Conditional Formatting | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Aung Shine
Aung Shine

Aung Shine completed his bachelor’s in Electrical and Electronics Engineering from Bangladesh University of Engineering and Technology. It has been almost 2 years since he joined SOFTEKO and actively working on the ExcelDemy project. Currently he works as a Team Leader where he guides his team members to create technical content. He has published 150+ articles and reviewed 50+ articles. He has also solved various user problems before. He has interests in Data Analysis, Power Query, Advanced Excel,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo