How to auto sort date when date is entered or changed in Excel?
In Excel, the Sort function can help you to sort date in ascending or descending order as you need. But it isn’t dynamic, if you have sorted the date and then add new date to it, you would need to sort it again. Are there any good and quick ways for you to auto sort the date when entering new date each time in a worksheet?
Auto sort date when date is entered or changed with formula
Auto sort date when date is entered or changed with VBA code
Auto sort date when date is entered or changed with formula
For example, the original date in Column A, the following formula can help you to auto sort the date or any other text strings in a new helper column based on the column that you want to sort, please do as follows:
1. Enter this formula:
=INDEX($A$2:$A$15,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$15,"<="&$A$2:$A$15),0)) into a blank cell beside your date column, C2, for example, and then press Ctrl + Shift + Enter keys together, and you will get a number sequence, then drag the fill handle down to the cells that you want to use, see screenshot:
Note: In above formula: A2:A15 is your original date range that you want to auto sort.
2. Then format the numbers as date format by clicking Short Date from the General drop down list under the Home tab, see screenshot:
3. Then the sequence numbers have been converted to date format, and the original date has been sorted as well, see screenshot:
4. From now on, when you entering new date or change the date in column A, the date in column C will be sort in ascending order automatically, see screenshot:
Auto sort date when date is entered or changed with VBA code
The following VBA code can help you to auto sort the date in the original column when you enter new date or change the date as you need.
1. Go the worksheet that you want to auto sort the date when you enter or change a date.
2. Right click the sheet tab, and select View Code from the context menu, in the popped out Microsoft Visual Basic for Applications window, please copy and paste the following code into the blank Module window, see screenshot:
VBA code: auto sort when date is entered or changed:
Private Sub Worksheet_Change(ByVal Target As Range) 'Updateby Extendoffice On Error Resume Next If Application.Intersect(Target, Application.Columns(1)) Is Nothing Then Exit Sub If Target.Count > 1 Then Exit Sub Range("A1").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub
Note: In the above code, the entered date will be auto sort in column A, you can change A1 and A2 to your own cells as you need.
3. From now on, when you enter date in column A, the date will be sorted ascending automatically.
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
- Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
- Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
- Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
- Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
- Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
- Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
- Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
- Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
- More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
