Share via

formulas in Excel

Yvonne Henry 20 Reputation points
2026-03-01T23:29:36.72+00:00

Attempting to calculate hours spent in Excel. Cells formatted to h:mm. When I subtract beginning from time from end time I get a #Value error that says wrong format type, and the results cell is now formatted as general. I'm using a simple formula of =j5-g5. What am I doing wrong.

Microsoft 365 and Office | Excel | For home | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. Q&A Assist
    2026-03-01T23:29:47.89+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The #VALUE! error with =J5-G5 means at least one of the referenced cells is not a valid Excel time value, even if it looks like one or is formatted as h:mm.

    Check and fix the following:

    1. Confirm the cells are real times, not text
      • Select J5 and G5. On the Home tab, in the Number group, change the format to General.
      • If they are valid times, you will see decimal values (e.g., 0.5 for 12:00 PM).
      • If you still see something like 08:30 or the cell is left‑aligned, the value is stored as text and will cause #VALUE!.
    2. Convert text times to real times
      For any cell that shows as text when formatted as General:
      • Re‑enter the time manually (e.g., type 8:30 and press Enter).
      • Or, if many cells are affected, use a helper column and a function that ignores text, such as =SUM(...), after cleaning the data as needed.
    3. Check for hidden spaces or special characters
      • A time like "08:30 " (with a trailing space) or with hidden characters will also cause #VALUE!.
      • Use tools like Find and Replace to remove spaces, or functions such as CLEAN or REPLACE as described in the context to strip problematic characters, then convert the result to values.
    4. Ensure the result cell is a time format
      After J5 and G5 are valid times, =J5-G5 will return a numeric result. Format the formula cell as h:mm (or a custom time format) so the duration displays correctly.

    If the error persists even with simple numeric subtraction (for example, =B1-A1 in a new workbook), check the Windows Region settings to ensure the minus sign is not configured as the list separator, as this can also cause #VALUE! in basic subtraction.


    References:

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Yvonne Henry 20 Reputation points
    2026-03-02T03:05:42.35+00:00

    I figured out I needed to add a space between the time and the am/pm. formula now works

    0 comments No comments

  2. Yvonne Henry 20 Reputation points
    2026-03-01T23:44:51.5033333+00:00

    answer was confusing


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.