How to Apply Conditional Formatting for Date Ranges in Excel
Question details
Highlight calendar cells dynamically if their dates fall within an event's start and end dates.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating an automated event tracker or timeline where dates between a specified start and end period are automatically colored.
- Observed behavior
- The user needs to set up a rule so that the appropriate cells change color when the corresponding calendar dates match the event duration, and this needs to automatically apply to newly added table rows.
Ensure your start and end dates are formatted as actual date values rather than plain text, and take note of the exact cell references for your calendar header row and event date columns.
Use an AND Formula for Conditional Formatting
Highlight cells dynamically by comparing the timeline column dates with the event start and end dates using a custom formula.
To make the highlight span across a date range, you must use a formula-based conditional formatting rule. By utilizing the AND function, you can check if a given calendar date is both greater than or equal to the start date and less than or equal to the end date.
Highlight the entire calendar grid where you want the colors to appear (e.g., H10:Z100). To accommodate new events later, extend this selection down to include empty rows at the bottom of your table.
Navigate to the 'Home' tab on the top ribbon, click on 'Conditional Formatting', and select 'New Rule' from the dropdown menu.
In the dialog box, select 'Use a formula to determine which cells to format'.
Type the formula: =AND(H$9>=$D10, H$9<=$E10). Replace H$9 with your first calendar date cell, $D10 with the start date cell of the first row, and $E10 with the end date cell of the first row.
Click the 'Format' button, navigate to the 'Fill' tab, choose your desired highlight color, and click 'OK' twice to apply the rule.

Create Dynamic Gantt Charts and Trackers with WPS Spreadsheet
WPS Spreadsheet fully supports advanced conditional formatting and custom formulas, making it incredibly easy to track event date ranges and visualize project timelines.
- 1. Open your tracker: Launch WPS Spreadsheet and open your timeline or event tracking document.
- 2. Select the calendar grid: Highlight the cells where the timeline colors should be displayed.
- 3. Add a new rule: Go to 'Home' > 'Conditional Formatting' > 'New Rule' and choose the formula option.
- 4. Input the formula: Enter your AND formula, customize the background fill color, and save the rule.

Frequently Asked Questions
Why is the formatting applying to the wrong rows or columns?
This usually happens when the cell references in your formula are locked incorrectly. Double-check that your event columns have a dollar sign before the letter (e.g., $D10) and the calendar row has a dollar sign before the number (e.g., H$9).
How can I ensure this rule automatically applies to new rows added to my table?
When setting up the Conditional Formatting rule, you can enter a larger range in the 'Applies to' box (e.g., extending it down to row 1000). Alternatively, format your data as an official Table (Ctrl+T), which automatically expands conditional formatting and formulas to newly added rows.
Can I use different colors for different types of events?
Yes. You can create multiple conditional formatting rules for the same calendar range. Just add an extra condition to your formula, such as =AND(H$9>=$D10, H$9<=$E10, $C10="Meeting"), and assign a unique fill color for each specific event type.




