View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Is it posible to set up some code to Filter Worksheet on Colours

Fred,

Not possible to directly filter by colour, but you could setup a UDF in VBA
and a helper column to get the ColorIndex and filter on that.

For instance, the UDF would look like

Function ColorIndex(rng As Range)
If rng.Count 1 Then
ColorIndex = CVErr(xlValue)
Else
ColorIndex = rng.Interior.ColorIndex
End If
End Function

and your helper column would have the formula
=colorindex(A1)
as an example.

Then filter the helper column by colour number (lookup the ColoIndex
Property in the VBA help, you will see the 56 colours in the standard
palette listed there).


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Frederick" wrote in message
...
I have a worksheet with various Rows and in some cases individual Cells
colour coded. Is it posible to set up say a Sub or Function to Filter out
either Rows or Cells based on the colour they contain.

Any help would be appreciated.

Regards.

Fred