View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Is there a way to count cells in a range with a given backcolo

I do not believe Excel has any inbuilt functions for working with cell
colours outside of conditional formatting so I suggest it's either a Sub or a
function.

"David" wrote:

Thanks, Mike. I knew how to do this by macro. I need a function, like
(pseudo code) "=if(interiorcolor=green, "Yes", "No").

I do recall reading an article some time ago about how this can be done.


"Mike H" wrote:

Checks a range for the same colour as in A1

Sub countcolours()
Clr = Range("A1").Interior.Color
Set Myrange = Range("B1:B100")
For Each c In Myrange
If c.Interior.Color = Clr Then
CountColour = CountColour + 1
End If
Next
MsgBox "There are " & CountColour & " cells the same colour as A1"
End Sub

Mike

"David" wrote:

Is there a function to count the cells in a range, which have a given
interior color?