How to Automatically Display an X in Excel Time Range Cells
Question details
The user wants to automatically populate timesheet cells with the letter 'X' whenever a recorded time falls within a specified time range, such as 9:00 to 17:00.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing daily employee timesheets or shift schedules where specific active hours need to be visually marked without manual data entry.
- Observed behavior
- The user currently has to manually type 'X' into the timesheet cells and is looking for an automated method using Excel formulas or conditional formatting rules.
Ensure your time data is properly formatted as Time (e.g., hh:mm) rather than plain text, so that Excel formulas and conditional formatting rules can accurately interpret the values.
Use an IF and AND Formula to Return 'X'
The most straightforward method to evaluate if a time falls within a specific range is to use a combination of IF and AND functions.
By utilizing the IF function alongside the AND function, you can check whether a specific cell's time value is greater than or equal to a start time, and less than or equal to an end time. If both conditions are met, the formula outputs an 'X'.
Click on the cell in your timesheet where you want the 'X' indicator to be displayed.
Enter the formula: =IF(AND(A2>=TIME(9,0,0), A2<=TIME(17,0,0)), "X", ""). Be sure to replace 'A2' with the reference to the cell containing your actual time value.
Press Enter to execute the formula. Click on the bottom-right corner of the cell and drag the fill handle down to copy the formula to the rest of your timesheet range.

Apply a Custom Number Format via Conditional Formatting
You can change how a cell looks without altering its underlying value by applying a custom number format through a conditional formatting rule.
Automate Timesheets Easily with WPS Spreadsheet
WPS Spreadsheet provides powerful formula support and advanced conditional formatting tools, making it incredibly simple to automate timesheets, track schedules, and manage time data efficiently.
- 1. Open your timesheet: Launch WPS Spreadsheet and open your existing timesheet or schedule file.
- 2. Enter your logical formulas: Select the target cell and input your IF and TIME formulas to accurately check the time range.
- 3. Apply Conditional Formatting: Use the Conditional Formatting tool located under the Home tab to easily set up visual indicators like an 'X'.

Frequently Asked Questions
Why isn't my IF formula recognizing the time values?
Time values in Excel are stored as decimal fractions of a 24-hour day. If your formula uses text like "9:00", it won't evaluate correctly against actual time cells. Always use the TIME(hours, minutes, seconds) function or reference cells containing properly formatted time.
Can I display different letters for different time shifts?
Yes, you can use nested IF functions or the IFS function to evaluate multiple time ranges in a single cell. For example, you can set the formula to return 'M' for a morning shift and 'N' for a night shift.
How do I hide the original time value and only show the 'X'?
If you are using the conditional formatting method, you can apply the custom number format ;;;"X". The three semicolons hide positive numbers, negative numbers, and zeroes, displaying only the text 'X' in their place.
How can I highlight the entire row if a cell contains an X?
Select your entire data range, go to Conditional Formatting > New Rule > Use a formula to determine which cells to format. Enter a formula with an absolute column reference, such as =$B2="X" (assuming column B holds the X), and set your desired fill color.




