Log in

View Full Version : Sort based on date then color



Ray.Mason
08-27-2012, 07:48 AM
Hi guys!

I have a 6 column table where currently I can filter dates in column 4 i.e. Ascending. However I also want to use column 6 as second filter based on bg color i.e. red, green, orange. I have looked at help page in vba but I can't seem to find any solution. Below is my current code that filters on column 3;
t.Sort _
ExcludeHeader:=True, _
FieldNumber:="Column 3", SortFieldType:=wdSortFieldDate, SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:=wdSortOrderAscending, _
FieldNumber3:="", SortFieldType3:=wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending

Any help will be greatly appreciated.

Many thanks!

Ray

macropod
08-27-2012, 11:30 PM
Hi Ray,

Unless you want to create your own colour-based sort routine, you'd probably do best to add a temporay column to the table, populate it with the numbers that correspond to to sort order you require for the colours, then use the built-in sort routine.

chandansify
08-30-2012, 01:25 AM
Hi guys!

I have a 6 column table where currently I can filter dates in column 4 i.e. Ascending. However I also want to use column 6 as second filter based on bg color i.e. red, green, orange. I have looked at help page in vba but I can't seem to find any solution. Below is my current code that filters on column 3;
t.Sort _
ExcludeHeader:=True, _
FieldNumber:="Column 3", SortFieldType:=wdSortFieldDate, SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:=wdSortOrderAscending, _
FieldNumber3:="", SortFieldType3:=wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending

Any help will be greatly appreciated.

Many thanks!

Ray


You can use Excel's to sort data for this requirement Sort by Font color/Cell Color in Excel 2010.

macropod
08-30-2012, 01:39 AM
You can use Excel's to sort data for this requirement Sort by Font color/Cell Color in Excel 2010.
That's all very well, but this is for Word.

chandansify
08-30-2012, 01:59 AM
That's all very well, but this is for Word.

True :thumb.

Personally, I would love to use Interop, as the functionality is already provided by MS in Excel.

Mix & Match of Office apps works :friends:

Cheers,