Displaying an Input Format in a Cell

Written by Allen Wyatt (last updated June 14, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

Greg uses Excel to calculate time which means he has a lot of formatted cells that look like this: Mar 10 15:00. People who use his worksheet constantly seem to enter time in a format other than his preferred format. For instance, they leave out the colon or the month and wonder why it won't calculate correctly. Greg has seen other Excel worksheets where the preferred format is "pre-entered" in each applicable cell for the user in a grayed-out form, such as: mmm dd hh:mm. Greg wonders how to do that with Excel.

There is no simple, easy way to do anything like this in Excel. The closest thing we've seen is the input mask feature available in Access, but not in Excel. It is possible that what Greg saw in other Excel worksheets was due to some add-in on that system or some set of complex macros that handled the display.

It is best to remember that the formatting of a cell is for display only, it does not affect the value of the cell itself. If the user does not enter a valid date and time or it is an incomplete date and time the value stored in the cell will be incorrect. Pre-entering the preferred date format into the cell will not prevent them from using other formats.

You could, if desired go the simple route and simply add comments (or notes if you are using Excel in Office 365) to the input cells. The comments or notes could explain the input format and even the importance of using the correct format. People would, of course, be able to ignore the comments or notes completely.

If this is a problem, one thing you could attempt is to "pre-enter" text displaying the desired format ("mmm dd hh:mm") and use conditional formatting to make the text gray when the cell has that particular text or make the explicit formatting gray and then conditional format it black when the cell is anything other than the example text. But that will not prevent the user from entering a date and time using a different format or misentering the values (by not including a needed piece of information).

Simple Excel pulldowns can be used to allow the user to select month, day, year, hour, and minute in separate cells and then use a formula to pull it together. You could even use more complicated means of data validation to ensure data is being entered in an acceptable manner, but a date and time are still numbers so checking the validity becomes difficult. Allowing easier entry is possible and some possible tips in doing things can be found at these pages:

https://excelribbon.tips.net/T012550_Using_an_Input_Mask.html
https://www.contextures.com/xlDataVal12.html
http://www.cpearson.com/excel/datetimeentry.htm

There are various "date picker" and "time picker" add-ins that people have created in Excel (some customizable, others not) that can be googled and tested or a custom one created in VBA.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (1113) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

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. ...

MORE FROM ALLEN

Deleting Caption Labels

Define a label to be used in a caption, and you may later want to delete that label. Here's how you can easily make the ...

Discover More

Getting Rid of Everything Except Numbers

Got some numbers and letters mixed up in the same cell? You may need to get rid of those letters so you are left with ...

Discover More

Ways to Combat Body Odor

Offensive body odor can be a problem for some people. If you need to reduce your body odor, there are several things you ...

Discover More

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 (ribbon)

Getting Rid of All Rows Except the One for the Latest Date

As you use Excel to collect data over time, sometimes winnowing out the latest data can present a challenge. Here are a ...

Discover More

Deleting Rows Containing Struck-Through Text

Excel makes it easy to delete rows in a worksheet, but it can be more difficult to figure how to delete rows if you only ...

Discover More

Default Cell Movement when Deleting

Delete a cell or a range of cells, and Excel needs to figure out how to rearrange the void left by the deletion. You can ...

Discover More
Subscribe

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

View most recent newsletter.

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}] (all 7 characters, in the sequence shown) 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 two more than 7?

2024-06-14 06:32:00

jamies

Also
given that the example is a date timestamp while the comment is about times
the "validation" would be better done requiring the date be entered as yyyy Mmm Dd - or, to avoid language considerations yyyymmdd
Remembering that 01/02 can be a fraction 0.5 or the second day of the year, or the 32nd day of the year, and that is assuming that the Christian calendar is in use for dates after 1899,.

And that times may be country, or location specific, with daylight adjustments - or GMT for a international workings such as airlines would need to use
And also needing to cope with clock adjustments giving 23, 24, or 25 hours in a date.

Then there is the date structures used in the far east etc., and pre-1900AD


2024-06-14 06:21:04

jamies

Set a Custom format for the display of the data using the +;-;0;text mode
[hh]:mm:ss;"Positive:times";"24:00:00 for midnight";"Enter time hh:mm:ss - with colons, and between 00:00:01 and 24:00:00"

Use data validation to limit the input
You can allow 00:00:00 rather than 24:00:00, and remember excel considers time to be fractional parts of a day.

You can also have a CF set to use "horrible shading, and font along with a "Enter is not a time - Do IT Right" message in an adjacent cell -
that adjacent cell looking at either the entry cell, or a block using a formula SUCH as
SUMPRODUCT((range>=0)*range(<=1)*ISNUMBER(range))=count(range)

Note COUNTA excludes blank (void) cells COUNT includes anything numeric, or blank (void)

Alternative - have the input as a text string and examine it for 1, or 2 ":" with the intervening characters being numeric digits values -
and the entry not giving an error if used in a TIME() function


2020-10-24 05:09:56

Ron S MVP

You can also (almost) use the validation feature. Although it doesn't show a 'preview' required format, you can set an "Input message", that includes desired format, to be displayed when the cell is selected. The message is displayed below the box as soon as the input point moves to that cell.


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
Subscribe

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.