Conditional Formatting in Excel is a technique where we format cells in a worksheet based on certain conditions, conditional formatting option is available in the styles section of the Home tab, there are various conditions provided by excel to use formatting on cells or a user can create a new rule for conditional formatting using a formula.
Conditional Formatting in Excel (with Formulas)
Conditional formatting is a feature in an excel spreadsheet that allows you to apply specific formatting to cells/range that meet the specified criteria/condition. The mostly formatting rule is used as color-based formatting to highlight or distinguish among data and information stored in an excel sheet.
- Conditional formatting formulaConditional Formatting FormulaConditional formatting using Formula is just changing the format of cells based on the user's condition or criteria. The outcome will be either TRUE or FALSE if all of the formulas are logical. provides the functionality to highlight cells with a certain color, depending on the cell’s value or a specific condition.
- It is a fantastic way to quickly visualize data in an excel sheet. By conditional formatting rules in Excel, you can highlight data with provided criteria.
- It allows you to visually analyze your data, based on a large number of condition types,
- Greater than, Less than, Between
- Above / Below Average
- Top / Bottom 10
- Top / Bottom 10%
- Duplicates / Unique
- Dates – Dynamic or a fix date range
- Text containing
How to apply conditional formatting in excel?
It will highlight the Cell A1 with red color if the value in A1 cell will be 1.
- Start Excel, and then open a new Excel worksheet.
- In the Excel worksheet, select any cell A1.
- Click Conditional Formatting in Excel Styles group, and then click New Rule.
- Click Use a formula to determine which cells to format under Select a Rule Type.
- Click inside the Format values where this formula is true. Then, select the cell that you want to use for the conditional formatting in excel.
- Modify the value in step 6 to be =$A$1=1.
- Click Format.
- In the Format Cells dialogue box, click the Fill.
- Click the color “red,” and then click OK.
- In the New Formatting Rule dialogue box, click OK.
- In cell A1, type 1, and then press the ENTER key.
- Verify that the color of the cell B1 changed to red.
- Close the Excel worksheet.
How to use the Conditional Formatting Excel Rule?
Let us understand working with simple examples.
Conditional Formatting Example #1
Highlight the data that is greater than 30.
Choose Highlight Cells Rules > Greater Than
Enter the number.
Below is the result:
Highlight the data with duplicate valuesHighlight The Data With Duplicate ValuesHighlight Cells Rule, which is available under Conditional Formatting under the Home menu tab, can be used to highlight duplicate values in the selected dataset, whether it is a column or row of a table..
Choose Highlight Cells Rules > Duplicate Values
Click on Duplicate and OK
The result will be:
Apart from simple rules like greater than and duplicates, there are others like “A Date Occurring…”. This condition is based on dates. Many conditions will have sub-conditions. This is one such example.
Here, we will select all the dates and apply the conditional format.
Choose Highlight Cells Rules > A Date Occurring.
Within this dialogue box, there are many date – related options available.
We will use ‘This Week’ as we want to highlight all the dates that fall in the current week. Likewise, you can use any other setting, as needed.
So the result will be:
Here we have a given data set of date and count, and we have to apply the multiple formatting rules.
First, we highlight the cell value that is between 31 and 43.
Select color yellow fill with Dark yellow text.
The result will be:
And then, apply another formatting on cells that have less than 0 value with the color of Light Red Fill with Dark Red Text.
And the Final Result will look like this:
You can use Data bars, color scale, and icon sets in excelIcon Sets In ExcelExcel icon sets are part of the conditional formatting graphics for numerical data sets. They help design the numbers more beautifully Directional, Shapes, Indicator, and Ratings are the many types of icon sets. for conditional formatting in ExcelFormatting In ExcelFormatting is a useful feature in Excel that allows you to change the appearance of the data in a worksheet. Formatting can be done in a variety of ways. For example, we can use the styles and format tab on the home tab to change the font of a cell or a table..
First, we will use Data bars in excelData Bars In ExcelData bars are a type of conditional formatting option in Excel that are used to highlight cells or data ranges in a worksheet based on certain criteria..
Go to Data Bars > Select Blue Data Bar.
Now, we will use Color Scales.
Go to Color Scales > Select any Color you want to.
Now, we will use the Icon Sets.
Go to Icon Sets > Select any icon you want to.
Finally, the table will look like this
Conditional Formatting can be used in VBA
We can apply the formatting rule using VBAApply The Formatting Rule Using VBAConditional formatting is also possible in Excel VBA programming by using the ‘Format Conditions Collection' macro/procedure. A conditional format is one that is applied only to cells that meet certain criteria, such as values above a certain threshold, positive or negative values, or values with a specific formula, and so on.; here is the example as follows:
With ThisWorkbookWith ThisWorkbookVBA ThisWorkbook refers to the workbook on which the users currently write the code to execute all of the tasks in the current workbook. In this, it doesn't matter which workbook is active and only requires the reference to the workbook, where the users write the code..Worksheets(1).Range(“B1”)
.FormatConditions.Add Type:=xlExpression, _
.FormatConditions(1).Interior.ColorIndex = 46
You can download this Conditional Formatting template here – Conditional Formatting Excel Template
This has been a guide to Conditional Formatting in Excel. Here we discuss how to use the Conditional Formatting formula along with excel example and downloadable excel templates. You may also look at these useful functions in excel –