View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David David is offline
external usenet poster
 
Posts: 1,560
Default Is there a way to count cells in a range with a given backcolo

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?