Sorting by Format?

R

RalphSE

.....this may be a candidate for dumbest question of the year on this
board but, here goes, - is it possible to sort by format features such
as highlighting for instance ... i have a table with rows highlighted
in different colors for certain reasons and need to organize them based
on that highlighting, cant seem to figure out how to do that if its even
possible?

:confused:
 
B

Bernard Liengme

I have copied this function from http://www.cpearson.com/excel/colors.htm

Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the Interior
' (background) of a cell, or, if OfText is true, of the Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

Use Tools|Macro|VBA Editor and then Insert|Module; copy this to the module
window

In an unused column call the function with a formula like
=CELLCOLORINDEX(A1,FALSE)

Copy down the column and use this as your sorting criterion
best wishes
 
J

Jim Cone

The next version of Excel will be able to sort by color.
You will have to wait to near the end of the year for its release.

The Chip Pearson color sorting code will not work on cells that
have been colored using conditional formatting.

Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html
http://www.realezsites.com/bus/primitivesoftware


in message...
....this may be a candidate for dumbest question of the year on this
board but, here goes, - is it possible to sort by format features such
as highlighting for instance ... i have a table with rows highlighted
in different colors for certain reasons and need to organize them based
on that highlighting, cant seem to figure out how to do that if its even
possible?
:confused:
RalphSE
 
R

RalphSE

thanks! but it doesnt appear to be working correctly, is is giving
inconsistent values, for example - it is returning the value 15 for red
highlighting with black text as well as no highlighting with black text,
i am just going to add a column and manually put in a number
corresponding to the color value so i can sort it that way, but thanks
kindly for your help...
 
Top