Fix an Excel IF Formula Returning a Cell Reference Instead of a Time
Question details
Return the end time from C6 when it is at or before 4:00 PM, or return 4:00 PM when it is later.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- An IF formula compares an end time with a 4:00 PM cutoff.
- Observed behavior
- The result displays =C6 instead of the time stored in C6.
Check that C6 contains a recognized Excel time value rather than text. Choose an unused cell, such as D1, for the 4:00 PM cutoff.
Reference the End-Time Cell Directly in the IF Formula
Use this formula to return the original end time or cap it at the time in D1.
A quoted entry such as "=C6" is text, so Excel displays those characters instead of retrieving the cell value. Use C6 without quotation marks or an equals sign inside the IF result.
Select D1, enter 4:00 PM, and press Enter.
Select the result cell and enter =IF(C6="","",IF(C6>$D$1,$D$1,C6)).
Select the result cell, open Home > Number Format, and choose Time.

Cap End Times at 4:00 PM in WPS Spreadsheet
Use the same IF formula in WPS Spreadsheet to return an end time or cap it at a cutoff, then format the result as a time.
- 1. Open the spreadsheet: Open your workbook in WPS Spreadsheet and locate the end time in C6.
- 2. Set the cutoff: Select D1, enter 4:00 PM, and press Enter.
- 3. Add the formula: Select the result cell and enter =IF(C6="","",IF(C6>$D$1,$D$1,C6)).
- 4. Apply time formatting: Select the result cell and choose Time from the number format options on the Home tab.

Frequently Asked Questions
Why does my IF formula display =C6 instead of the time?
The formula may contain "=C6" in quotation marks, which makes it text. Edit the formula and use C6 without quotation marks for the result.
What happens when the end time is exactly 4:00 PM?
The formula returns C6 because it uses the greater-than operator. Since C6 equals the cutoff, the displayed result is still 4:00 PM.
Why does the formula result appear as a decimal?
Excel stores times as numeric values. Select the result cell and choose Time under Home > Number Format to display it as a time.
Can I copy the formula down for other end times?
Yes. Drag the result cell's fill handle down. The C6 reference changes for each row, while $D$1 remains fixed on the cutoff cell.




