Conditional Formatting is an excellent way to visualize the data based on certain criteria. The AND function in the Conditional Formatting highlights the data in the table if at both of the defined conditions are met. This step by step tutorial will assist all levels of Excel users in highlighting rows with dates between using Conditional formatting and the AND function.
Figure 1. Final result
Syntax of the AND formula
=AND(logical1, [logical2], …)
The parameters of the AND function are:
- Logical1, logical2 – the conditions that we want to test
The output of the formula is value TRUE if just all of the conditions are met. If at least one of the conditions is not met formula result will be FALSE
Setting up Our Data for the Conditional Formatting
Our table consists of 3 columns: “Delivery Number” (column B), “Delivery Date” (column C) and “Amount” (column D). In cells G2 and G3, we specify a date range. We want to highlight all rows that have Delivery Date between Date From and Date To (in October).
Figure 2. Data that we want to format using Conditional Formatting
Create an AND formula rule in the Conditional Formatting
To create a Conditional Formatting rule based on the formula we should follow the steps below:
- Select the cell, cell range or table in Excel where we what to apply the Conditional Formatting
Figure 3. Select a cell range for the Conditional Formatting
- Find Conditional Formatting button tab and choose New Rule
Figure 4. Create a new rule in the Conditional Formatting
- Choose Use a formula to determine which cells to format
Figure 5. Create a formula rule in Conditional Formatting
- Enter formula rule under the section Format values where this formula is true
=AND($C3>=$G$2, $C3<=$G$3)
Figure 6. AND function in Conditional Formatting
The formula above highlights the rows in the example table where Delivery Date is between 1-Oct-18 and 31-Oct-18. AND function checks if both conditions are met and returns the value TRUE. This value triggers the Conditional Formatting rule.
In our AND formula example there are two logical tests:
- Logical1 is $C3>=$G$2 – checks if Date is greater than or equal to 1-Oct-18
- Logical2 is $C3<=$G$3 – checks if Date is lower than or equal to 31-Oct-18
- Under the Format tab, we can define the visual appearance of the cells if the AND formula output is TRUE
Figure 7. Create a custom format in Conditional Formatting
- In Fill tab, choose the background color (here you can also choose pattern style and color)
Figure 8. Define a Background Color of the cells
- In the Font tab, we can define font style and Bold cell text
Figure 9. Choose a Font style of the cells
- After choosing the format in section Preview we can see how Conditional Formatting cells will look like if the rule is met
Figure 10. Conditional Formatting rule Preview
- Rows in the table are highlighted whenever the date is between G2 (1-Oct-18) and G3 (31-Oct-18)
Figure 11. Conditional Formatting AND formula rule
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.
Leave a Comment