Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to sort dates automatically upon entry or change in Excel?

Author Xiaoyang Last modified

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 to auto-sort dates when entering new data 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


arrow blue right bubble Auto sort date when date is entered or changed with formula

For example, if the original dates are in Column A, the following formula can help you auto-sort the dates or any other text strings into a new helper column based on the column you want to sort. Please follow these steps:

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 to get a number sequence. Next, drag the fill handle down to the desired cells. See screenshot:

Note: In above formula: A2:A15 is your original date range that you want to auto sort.

A screenshot showing the application of a formula in Excel to auto-sort dates

2. Then format the numbers as date format by clicking Short Date from the General drop down list under the Home tab, see screenshot:

A screenshot showing how to format sorted numbers as dates in Excel

3. The sequence numbers are now converted to date format, and the original dates have been sorted as well. See screenshot:

A screenshot showing the result of converting sorted numbers to date format in Excel

4. From now on, when you enter or change a date in column A, the dates in column C will be sorted in ascending order automatically. See screenshot:

A screenshot showing automatically sorted dates after entering new data in Excel


arrow blue right bubble Auto sort date when date is entered or changed with VBA code

The following VBA code can help you auto-sort dates in the original column when you enter or change a date as needed.

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

A screenshot of VBA code being entered in the Visual Basic editor for auto-sorting dates

Note: In the above code, the entered dates will be auto-sorted in column A. You can change A1 and A2 to your own cells as you need.

3. From now on, when you enter a date in column A, the dates will be sorted in ascending order automatically.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


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!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in