View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default Counting coloured cells

Hi

You can add some conditions to the if statement:

If cell.Interior.ColorIndex = 6 And cell.Value < "" And cell.Value = 0 Then

If you use the below it will count empty cells as 0:

If cell.Interior.ColorIndex = 6 And cell.Value = 0 Then

Regards,
Per

"SNC-DW" skrev i meddelelsen
...

Hi

I've used the following code to count the number of cells in a range
that are filled yellow, using the basic funtion '=CountYellow(A1:A99)'

Function CountYellow(MyRange As Range)
Dim iCount As Integer
Application.Volatile
iCount = 0
For Each cell In MyRange
If cell.Interior.ColorIndex = 6 Then
iCount = iCount + 1
End If
Next cell
CountYellow = iCount
End Function

However I now need to count the same range of cell that are coloured
but contain only zeros, any ideas?

Thanks




--
SNC-DW