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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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.
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,677
Members
449,092
Latest member
tayo4dgacorbanget

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
Back
Top