Please Note:
This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Entering or Importing Times without Colons.

Entering or Importing Times without Colons

When you enter a time into a cell, Excel keys on the presence of the colon between the hour and minute portions of the time. Because of the position of the colon on the keyboard, however, entering a colon for each time value that you enter can slow you down—particularly if you have quite a few time values to enter.

For this reason, you may wonder if there is a way to skip entering the colon and either have them entered automatically or entered all at once. Entering them automatically takes a bit more doing, requiring the use of a macro, and will be covered shortly. Entering the colons all at once can be done with a formula, as in the following:

=TIMEVALUE(REPLACE(A1,3,0,":"))

This formula assumes that the time value (without a colon) is in cell A1, and that it is comprised of four digits. Thus, if cell A1 contains a value such as 1422, then the formula returns 14:22 as an actual time value. (You may need to format the cell as a time value.)

If your original entry cell might contain a time that uses only three digits, such as 813 instead of 0813, then you need to use a slightly different formula:

=TIME(LEFT(A1,LEN(A1)-2),RIGHT(A1,2),0)

If you prefer for the insertion of the colons to happen automatically, you can use a macro. You can create a macro that will examine a range of cells where you plan on adding dates to the worksheet, and then insert the colon in the entry. This is done by creating a macro that is triggered by the SheetChange event. The following macro is one such:

The first thing the macro does is to check to see if the data that was just entered was in the range C7:D15. If it wasn't, then the macro exits. It also checks to make sure that there is only a single cell selected and that the cell isn't empty. If all these criteria are met,, then the macro checks the length of the value in the cell and pads it out with leading zeroes, as necessary. This macro is based on a macro found at Chip Pearson's site, here:

ExcelTips is your source for cost-effective Microsoft Excel training.
This tip (2412) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Entering or Importing Times without Colons.

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. Learn more about Allen...

MORE FROM ALLEN

Setting a Length Limit on Cells

Limiting what can be entered in a cell can be an important part of developing a worksheet that other people use. Here's a ...

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Adjusting Times for Time Zones

Collect a series of times in a worksheet, and you might need to adjust those times for various time zones. This involves ...

Comments

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.

Source

(gif, jpeg or png only, 5MB maximum file size)

Source

(gif, jpeg or png only, 5MB maximum file size)

Source

(gif, jpeg or png only, 5MB maximum file size)

Notify me about new comments ONLY FOR THIS TIP

Notify me about new comments ANYWHERE ON THIS SITE

Hide my email address

What is six more than 8?

There are currently no comments for this tip. (Be the first to leave your comment—just use
the simple form above!)