# Sorting rows in Excel 2013 based on when they were added [closed]

Is there a way to sort rows in Excel 2013 based on when the rows were added?

## closed as unclear what you're asking by DavidPostill♦, Ƭᴇcʜιᴇ007, mdpc, Simon Sheehan, RaystafarianAug 5 '15 at 18:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Excel doesn't have a way to track when cells were added so without a specific column stating when it was added you can't do this. – gtwebb Jul 27 '15 at 18:03
• meta.superuser.com/q/10696/468548 – User15 Sep 7 '15 at 13:29

Sure, just assign one of the columns in your data to the date. When you enter values in the row, enter today's date in that column. Once you have completed entering the row data, sort the table by the date column.

The most effective solution will depend largely on how your workbook is constructed. I suggest the following:

Designate column A to track the dates and times at which new rows are added. You can then hide column A so nobody sees it (select the entire column and set the width to 0). Next, try the following macro:

Sub InsertRowWithDate()

Dim CurrentDate As String, CurrentTime As String
CurrentDate = Format(Date, "MMM DD, YYYY")
CurrentTime = Format(Time, "HHMM")

'Inserts a new row above the currently selected cell

Rows(ActiveCell.Row).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

'Inserts the current date and time into Column A of the row just inserted.

Cells(Application.ActiveCell.Row, "A").Value = CurrentDate & " " & CurrentTime

End Sub


this will insert a new row above whatever cell you have selected. The current date and time will be placed into your hidden column A.

Assign an easy to remember hot key, or button to this macro for easy access. Now you can simply sort your data by column A.

If you want your macro to automatically sort the data each time you insert a new row, we can make that happen too.

Let me know if this works for you.