Formula Errors

How to Fix Excel #VALUE! Errors from Invalid 24-Hour Times

Amos GikundaAmos Gikunda Nov 10, 2026 869 views

Question details

The user needs to resolve #VALUE! errors in Excel that occur when subtracting time values containing invalid formats.

How to Fix Excel #VALUE! Errors Caused by Invalid 24-Hour Times
Product
Excel
Device & OS
not provided
Scenario
Subtracting time values where the source data incorrectly combines a 24-hour clock format with a 12-hour AM/PM suffix (e.g., 13:06 PM).
Observed behavior
Excel fails to recognize the invalid time format, treating it as text, which results in a #VALUE! error when performing mathematical calculations like subtraction.
Before you start

Ensure your result cells are formatted as Time or Custom (such as [h]:mm) so that the corrected values display properly after calculation.

Solution 1Recommended

Correct Invalid Time Entries and Recalculate

Fix the source data by choosing either a strict 24-hour format or a strict 12-hour format, then perform the subtraction normally.

Excel requires time entries to strictly follow either a 12-hour format with AM/PM or a 24-hour format without AM/PM. Mixing them forces Excel to treat the cell contents as a text string instead of a numerical time value.

1
Identify invalid time entries

Check your source data for cells that contain both a 24-hour number (like 13 to 23) and an 'AM' or 'PM' suffix, such as '13:06 PM'.

2
Standardize the time format

Edit the cell to use a valid 24-hour format (change '13:06 PM' to '13:06') or a valid 12-hour format (change to '1:06 PM').

3
Perform the time subtraction

In the target cell where you want to see the time difference, enter your subtraction formula, such as =AD2-AB2.

4
Format the result cell

Right-click the cell containing the formula, select 'Format Cells', navigate to the 'Custom' category, and enter [h]:mm or h:mm to display the elapsed time correctly.

Correct Invalid Time Entries and Recalculate
Formatting Tip: Correctly formatting your time values ensures the spreadsheet software recognizes them as numbers rather than text, preventing #VALUE! errors in all future calculations.
Manage Data with WPS Spreadsheet

Calculate Time Differences Flawlessly in WPS Office

WPS Spreadsheet provides powerful cell formatting and formula error checking tools, making it easy to fix time formatting issues and calculate elapsed times accurately.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open the workbook containing your time data.
  2. 2. Format cells properly: Select the cells with time data, right-click, and choose 'Format Cells'.
  3. 3. Standardize time inputs: Apply a standard 'Time' format or set a custom h:mm format to standardize inputs and clear invalid text values.
  4. 4. Calculate differences effortlessly: Use simple subtraction (e.g., =B2-A2) to calculate time differences without encountering value errors.
Quickly identify and fix formula errors with built-in error checking.Extensive custom cell formatting options for time, date, and elapsed hours.Fully compatible with Microsoft Excel (.xlsx) formats and formulas.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my spreadsheet show #VALUE! when subtracting times?

This happens if one or both time values are recognized as text instead of numbers. This is often caused by invalid formatting, like mixing 24-hour times with AM/PM suffixes, or accidentally including hidden spaces.

What is the best cell format for displaying total hours over 24?

Use the custom format [h]:mm. The square brackets tell the spreadsheet program to display cumulative elapsed time rather than resetting the hour count to zero after 24 hours.

Can I use Find and Replace to fix the 'PM' suffix error?

Yes. You can use the Find and Replace tool (Ctrl+H) to find ' PM' (with a leading space) and replace it with nothing. This will quickly convert invalid 13:00 PM entries into valid 24-hour formats like 13:00.