In this article, you will learn how to automatically sort dates as you enter in the worksheet.
Q) I have a spreadsheet that's getting updated with new date entries every day. I'd like to sort the rows by newest date (date is in column C), and anytime I add a new date at the bottom I'd like it to automatically sort itself into the list after I enter it. Is there an easy way to do this?
Let us take an example:
Following is a picture of the data we have
Following is the snapshot of the result we would like to see as we enter information.
Click on Developer tab
From Code group, select Visual Basic
Enter the following code in the sheet you are working. (sheet1 in our example)
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Range("A1").Sort Key1:=Range("C2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
In this way, you can easily sort the data by Dates column after entering the information. This will save our time in doing manual steps for sorting the data.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.