Show a Message When a Starting-Time Cell Is Blank in Excel
Question details
Show a clear message when the starting-time cell is blank instead of calculating a time difference.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet calculates elapsed time by subtracting the starting time in G2 from the ending time in J2.
- Observed behavior
- When G2 is blank, the calculation may treat it as zero and display a misleading result.
Check that G2 is the starting-time cell and J2 is the ending-time cell, and adjust the references if your worksheet uses different columns. Enter valid Excel time values in both cells before calculating the difference.
Use IF to show a warning for a blank starting time
Use this formula when you want a formatted time difference or a clear warning in the same result cell.
Click the cell where you want the time difference or warning to appear.
In the formula bar, enter =IF(G2="","PLEASE FILL CELL G2",TEXT(J2-G2,"h:mm")) and press Enter.
Leave G2 blank to check that the warning appears, then enter valid times in G2 and J2 to see the formatted difference.

Keep the time difference numeric for further calculations
Use this option when you need to add or otherwise calculate with the resulting duration.
Show blank-cell warnings in WPS Spreadsheets
Use the same IF and TEXT formula in WPS Spreadsheets to display a warning when the starting time is missing and a formatted difference when it is present.
- 1. Open the spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
- 2. Select the result cell: Click the cell where you want the time difference or warning to appear.
- 3. Enter the formula: Enter =IF(G2="","PLEASE FILL CELL G2",TEXT(J2-G2,"h:mm")) in the formula bar and press Enter.
- 4. Check the formula: Leave G2 blank to see the warning, then enter valid times in G2 and J2 to check the result.

Frequently Asked Questions
Why does a blank starting-time cell produce a time result?
Excel may treat a blank cell as zero in subtraction. Test G2 first with IF(G2="","PLEASE FILL CELL G2",J2-G2) to show a warning instead.
Will the blank-cell test allow midnight as a starting time?
Yes. The test G2="" checks for a blank value, while midnight is stored as the numeric value zero. A simple IF(G2,...) test would treat that zero as false.
Can I add the displayed time differences together?
The TEXT function returns text, so use =IF(G2="","PLEASE FILL CELL G2",J2-G2) for numeric results. Then open Format Cells and apply the custom format [h]:mm.
What if the shift ends after midnight?
If G2 and J2 contain times without dates and the shift crosses midnight, use MOD(J2-G2,1) for the difference. For example, enter =IF(G2="","PLEASE FILL CELL G2",TEXT(MOD(J2-G2,1),"h:mm")) in the result cell.




