Function Problems

Show a Message When a Starting-Time Cell Is Blank in Excel

Anum MushtaqAnum Mushtaq Nov 22, 2026 868 views

Question details

Show a clear message when the starting-time cell is blank instead of calculating a time difference.

Show a Message When a Starting-Time Cell Is Blank in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Select the result cell

Click the cell where you want the time difference or warning to appear.

2
Enter the formula

In the formula bar, enter =IF(G2="","PLEASE FILL CELL G2",TEXT(J2-G2,"h:mm")) and press Enter.

3
Test the result

Leave G2 blank to check that the warning appears, then enter valid times in G2 and J2 to see the formatted difference.

Use IF to show a warning for a blank starting time
Check the ending time: This formula checks only G2, so make sure J2 also contains a valid ending time. The explicit blank check allows midnight, which Excel stores as zero, to be used as a starting time. TEXT returns the result as text rather than a numeric duration.
Calculate time in WPS Spreadsheets

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. 1. Open the spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
  2. 2. Select the result cell: Click the cell where you want the time difference or warning to appear.
  3. 3. Enter the formula: Enter =IF(G2="","PLEASE FILL CELL G2",TEXT(J2-G2,"h:mm")) in the formula bar and press Enter.
  4. 4. Check the formula: Leave G2 blank to see the warning, then enter valid times in G2 and J2 to check the result.
Warns when the starting-time cell is blankSupports Excel-compatible XLSX and XLS filesProvides familiar spreadsheet formulas and formattingOffers a free way to edit spreadsheets
QA img-9

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.