Sorting Recording based on background or font color?

ramki

New Member
Joined
Oct 13, 2006
Messages
23
Hi,

Is it possible to sort the excel records based on background or font color?. Please Help!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

will_simpson

New Member
Joined
Oct 17, 2006
Messages
29
Not much to go on but....

.......if your data is in a column, has no gaps between it and a spare column to the right then the code below should work for you

Sub Decode_sort_bycolour()

ActiveWorkbook.Names.Add Name:="Starter", RefersTo:=ActiveCell(1, 2)

Do

ActiveCell(1, 2).Value = ActiveCell.Interior.Color
ActiveCell(2, 1).Select

Loop Until ActiveCell.Value = ""

Range(ActiveCell(0, 1), "Starter").Select

Selection.Sort Key1:=Range("Starter"), Order1:=xlAscending, HEADER:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Selection.End(xlDown).Select
Selection.End(xlToRight).Select

Range(ActiveCell, "Starter").Clear


End Sub


You could change the "interior" bit above to "font" if you wanted to sort on that instead.

Also this will only sort the data in order of the number assigned to the colour of the cell / font.
 

Forum statistics

Threads
1,136,347
Messages
5,675,235
Members
419,555
Latest member
Paddington

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top