Written by Allen Wyatt (last updated November 18, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021
When Ted enters a date with just the month and day, i.e. 11/5, the date displays 5-Nov and the number format is Custom. However, when he enters 11/5/23 the date displays 11/5/2023 and the number format is Date. Ted wonders how he can get the date to format to 11/5/2023 when he enters only 11/5 without having to format the cells to Date before making his entry. In other words, he wants the date to default to Date and not Custom.
There is no way to do this within Excel. In this case, Excel, as part of its parsing process, chooses the date format that it believes you intended based upon how you entered the date. If you want to use a different date format, you must explicitly format the column (or cells) to use the date format you want before you enter the date, or you must format the column (or cells) explicitly after you enter the date.
There is one macro-based solution, but it may be a bit of overkill. All you need to do is to add this event handler to the code window for the worksheet. (Right-click on the worksheet tab and choose View Code from the resulting Context menu. Paste this short macro into the code window that then appears.)
Private Sub Worksheet_Change(ByVal Target As Range) If IsDate(Target) Then Target.NumberFormat = "m/d/yyyy" End If End Sub
The macro checks whatever you enter into a cell, and if it is determined to be a date (that's the purpose of the IsDate function), then the desired date format is applied to the cell.
I mentioned that this may be a bit of overkill because you will, obviously, need to save the workbook as a macro-enabled workbook. If this is no problem for your use of the workbook, however, then it may solve your date-formatting needs.
Honestly, the easiest way to handle this is the way that Ted stipulated he didn't want to do—simply format the cells to the Date format before you start doing your entries.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13553) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Excel allows you to apply several types of alignments to cells. One type of alignment allows you to indent cell contents ...Discover More
Need the contents of a cell to be shown in a direction different than normal? Excel makes it easy to have your content ...Discover More
You can use the Paste Special feature in Excel to multiply the values in a range of cells. If you don't want Excel to ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.