Checking for Data Entry Errors for Times

by Allen Wyatt
(last updated September 13, 2014)


King notes that if a cell is formatted as hh:mm or [h]:mm and you accidentally enter 3:555 in the cell, you get 12:15 instead of 3:55. Excel is interpreting the 555 as 555 minutes, not 55 and 1/2 minutes. He wonders if there is a way to guard against such data entry errors, as he cannot get data validation to handle it.

King is correct; data validation won't handle this type of error. If you set data validation to allow Time entry into a cell and then set the bounds to be 12:00:00 am to 11:59:59 pm (so that any time is allowed), it will still accept 3:555 and misinterpret it as 3 hours and 555 minutes, or 12:15. Since 12:15 is within the allowed range of times, data validation sees no problem.

Data validation could still be used, however, if you split your time input to two cells. Allow the user to input hours into one cell and minutes into another, and use data validation to enforce acceptable input parameters for each cell. This would stop 555 from being accepted as a valid number of minutes. You could then convert the two cells into a valid time in this manner:


Several subscribers suggested using a macro to check the contents of the cell and stop the typo entry. Each suggestion relied upon the Worksheet_Change event handler, which seemed very promising. None of the solutions that were provided, however, would capture the entry of 3:555 as incorrect. The reason is that by the time Excel handed control over to the Worksheet_Change event, its internal routines had already parsed the entry and changed it to 12:15. While 3:555 could be programmatically flagged and adjusted, the parsed 12:15 could not—it is still considered a valid time, so it sailed right through any of the Worksheet_Change macros.

The only macro-based solution, then, would be one that uses an inputbox for the user to enter a time which could be verified before the macro inserts it in the worksheet. This approach, however, seems much more disruptive to easy user input than to use separate minute and second cells and apply data validation to those cells.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13248) applies to Microsoft Excel 2007, 2010, and 2013.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Searching for Special Characters

When using the Find and Replace feature of Word, you can search for more than plain text. You can also search for ...

Discover More

Word 2010 Mail Merge Magic (Table of Contents)

The mail merge tool available in Word is powerful, allowing you to use data from a variety of sources to create hundreds ...

Discover More

Error in Linked PivotTable Value

Excel allows you to link to values in other workbooks, even if those values are in PivotTables. However, Excel may ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Dealing with Midnight Ending a Day

Dealing with times in Excel is fairly straightforward, except when it comes to midnight. Some people prefer that midnight ...

Discover More

Working with Elapsed Time

Work with times in a worksheet and you will eventually want to start working with elapsed times. Here's an explanation of ...

Discover More

Dealing with Large Numbers of Seconds

When adding values to a time to calculate a new time, you may naturally choose to use the TIME function. This can cause ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 3?

2014-09-16 13:16:41


Mike ... I suggest then creating a user dialogue form where you can take full control of any users input. I does take a bit more programming skill, but you will be able to manage all input parameters including input formatting and raise errors as needed to inform the user.

2014-09-15 08:38:38


Just be aware that data validation can be bypassed when pasting into a cell.

2014-09-15 06:46:18


Thanks for the input guys. King submitted this on my behalf. I am creating a spreadsheet to log "Attention Required Now" times in up to 40 different cells on a spreadsheet log for our Temperature Chambers, and have upwards to two dozen people making the entries. So I have to make it foolproof in regards to a fat-fingered entry of say "444" for minutes instead of the intended "44". What I ended up doing is formating all 40 of the cells to TEXT and made a range in Data Validation for the 1441 time-to-the-minute possibilities from "00:00" thru "23:59". Not what I desired, but it works.

2014-09-15 03:34:45

Wim Torfs

I use this
3 12 13 3:12:13

2014-09-13 19:08:07

Bob Beechey

I am disappointed you did not try my macro which, against your statement, worked perfectly. Like Locke's suggestion, it depended upon the time entry taking place in a column pre-formatted as text. This allows validation before the macro converts it to any chosen time format.

2014-09-13 18:16:59


What about making the number format of the data entry range for time the "Text" number format. Then you could use your Worksheet_Change events to validate against 3.555 as well as reformat the valid times the way you want it to look with the macro below (Assuming the data entry column is column A).

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 1 Then 'Data Entry Time Input Column

If IsDate(Target.Value) Then
Target.Value = Format(TimeValue(Target.Value), "h:mm AM/PM")
Target.Interior.Pattern = xlNone
Target.Font.ColorIndex = xlAutomatic
'Mimic the "Bad" range style colors
Target.Interior.Color = RGB(255, 199, 206)
Target.Font.Color = RGB(156, 0, 6)
End If

End If

End Sub

On a side note, I realized in testing this that VBA's TimeValue function appears to be superior to Excel's TimeValue worksheet function in that VBA can successfully convert "3:59p", but Excel needs it to read "3:59 p".

2014-09-13 12:15:20


If you'd rather not do math to convert the hours and minutes into an Excel serial number, Excel's built-in TIME function will do it for you:

2014-09-13 09:56:52


What I do sometimes when I am doing data entry like times, or field measurements for projects, is turn on the text-to-speech feature "Speak cells on enter" in Excel. This helps me by having Excel speak the entry I inputted so I can hear the value to make sure it was entered correctly. I have the Speak cells on enter tool readily available on the Quick Access Toolbar.

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.