Excel Conditional Formatting for Times Inside or Outside a Range
Question details
Apply different colors to times inside and outside a specified range.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains times that should be colored purple from 3:10 PM through 3:25 PM and brown outside that range.
- Observed behavior
- Times at or between the two endpoints should appear purple; earlier and later times should appear brown.
Make sure the cells contain actual Excel time values rather than text, and that they do not include a date. Identify the first cell in the range you want to format; the example below uses F7:F14.
Create Two Formula-Based Conditional Formatting Rules in Excel
Use one rule for the inclusive time range and another for times outside it.
Select F7:F14, or select your own range and replace F7 in both formulas with its top-left cell.
Go to Home > Conditional Formatting > New Rule, choose Use a formula to determine which cells to format, and enter =AND(F7>=TIME(15,10,0),F7<=TIME(15,25,0)).
Click Format, choose a purple fill, and click OK to save the rule.
With the same cells selected, go to Home > Conditional Formatting > New Rule, choose the formula option, and enter =OR(F7<TIME(15,10,0),F7>TIME(15,25,0)).
Click Format, choose a brown fill, and click OK to save the rule.

Color Time Ranges with WPS Spreadsheet
Use formula-based conditional formatting in WPS Spreadsheet to assign different colors to times inside and outside the selected range.
- 1. Open and select the cells: Open the workbook in WPS Spreadsheet and select F7:F14, or your own range of time cells.
- 2. Add the inside-range rule: On the Home tab, open Conditional Formatting > New Rule, choose the formula-based rule option, and enter =AND(F7>=TIME(15,10,0),F7<=TIME(15,25,0)). Replace F7 with your selection's top-left cell if needed.
- 3. Choose purple: Open the rule's Format settings, select a purple fill, and save the rule.
- 4. Add the outside-range rule: Create another formula-based rule for the same selection using =OR(F7<TIME(15,10,0),F7>TIME(15,25,0)), and choose a brown fill in Format.

Frequently Asked Questions
Are 3:10 PM and 3:25 PM included in the purple range?
Yes. The inside-range formula uses >= and <=, so both endpoints are included.
How do I apply the formulas to a different range?
Select your range before creating the rules and replace F7 in both formulas with the range's top-left cell. Leave the reference relative so it adjusts for each cell.
Why are blank cells turning brown?
Excel can evaluate a blank cell as zero in the outside-range formula. To exclude blanks, use =AND(F7<>"",OR(F7<TIME(15,10,0),F7>TIME(15,25,0))) for the brown rule.
Will these rules work if a cell contains a date and time?
Not as written: a date adds a whole-number component to the value. Use =MOD(F7,1) in place of F7 in the comparisons to evaluate the time portion, and account for blank cells separately if needed.
Why is my conditional formatting formula not working?
In Home > Conditional Formatting > Manage Rules, check that the formula starts with =, has no surrounding quotation marks, and refers to the top-left cell of the applied range. Also confirm the cells contain real time values rather than text.




