Monday, December 13, 2010

Sorting Dates in Excel 2007

This issue has perplexed me off and on for the past two years! I am documenting the solution here in this Blog more for myself than anyone else. I must have spent a whole hour researching this issue, VLOOKUP, DBA, all kinds of solutions but not quite the one I was looking for.

Issue: Sorting on dates not working correctly because the sort key would be based on the month digit as text instead of a number. i.e. 1/1/2010 would be followed by 1/2/2008
Solution: Tell the sort to treat the dates as numbers instead of text.

Implementation:
We assume that the data has column headers and at least one column with dates.
Note: There are several ways to accomplish this, so whatever works for you, but this is how I do it.

Make sure that data filtering is active.
  • Home tab > Editing Box > Sort & Filter > Filter
Now that filtering is on, sort data based on the date column.
  • Home tab > Editing Box > Sort & Filter > Custom Sort
In the dialog box that pops up asking for the sort key or sort order.
  • Sort by "Dates Column"; Sort on "Values"; Order "A to Z"
Here is where we get to the crux of the data sort by selecting the appropriate option on the next dialog box.
  • Sort Warning Dialog Box pops up.
  • Asks what you would like to do because your column header has text, but the column also has "date" values.
Always select "Sort anything that looks like a number, as a number".

Eia la! Our data is sorted and ready for manipulation.

Happy Times!

2 comments:

Loli Ma'o & Noland Makapi Ma'o said...

hey brother you are the KING OF EXCEL... love you... now with the my new job I have been working a lot with EXCEL... and finding all new ways and tricks... love you brother keep updating me...

Liko said...

Sister! So glad you found this useful! E-mail me and tell me what new job you have and everything else that has been going on.

Love you!