Excel formula sorting data by date but group by column value

microsoft excelworksheet-function

Morning people

I've been roped into helping someone with an excel sorting issue and I've got myself a bit stuck to be honest. I need to sort a spreadsheet by date (oldest to the newest) but group the data by groups.

So the date looks like this

ColumnA ColumnB ColumnC
1          15    2007-07-01
2          16    2007-08-12
3          16    2011-08-01
4          15    2001-01-02
5          17    2002-08-07
6          17    2012-04-02

So I need to sort the all the data by date but I need them also sorted in groups depending on the value in column be so all the groups should be together e.g.

  ColumnA ColumnB ColumnC
    4          15    2001-01-02
    1          15    2007-07-01
    2          16    2007-08-12
    3          16    2011-08-01
    5          17    2002-08-07
    6          17    2012-04-02

Whats the best way to tackle this?

Cheers

Edited:

ColumnA ColumnB ColumnC
    4          15    2001-01-02
    1          15    2007-07-01
    5          17    2002-08-07
    6          17    2012-04-02
    2          16    2007-08-12
    3          16    2011-08-01

Best Answer

All you need is simple 2 columns sorting: Ribbon Data > Sort, add 2 levels of sorting as shown below (dates are formatted using my own regional settings, so don't worry about that):

2 cols sort

And here it is:

Result

UPDATE:

As per updated conditions, groups in column B should be sorted according to oldest date in group, while the groups are still stacked together. This may be achieved via intermediate calculation column. Type in D1 the following formula:

=MIN(IF($B1=$B:$B,$C:$C,2^100))

but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in curly {} brackets around it (but do NOT type them manually!).

Then, perform sorting as suggested above, but with the following set of options:

Column D / Values / Smallest to Largest
Column C / Values / Oldest to Newest

This will result in desired output. After sorting column D may be removed.

Related Question