Count Red Cells on a worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am looking for a way to count the number of Red Cells on a worksheet and
return that number is a message box. Thanks in advance!
 
Something along these lines should work.

If cells are colored by conditional format:

For Each c In myRange
If c.FormatConditions.Interior.ColorIndex = 3 Then
'Do something
End If

If cells are colored by standard format or code:

For Each c In myRange
If c.Interior.ColorIndex = 3 Then
'Do something
End If
 
Here is code that will work if the cells are red by standard format method.

Sub cntclr()
Count = 0
For Each C In Worksheets(1).Range("A1:F20") 'Change range for needs.
If C.Interior.ColorIndex = 3 Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub
 
Aaron said:
What if it is a conditional formatting that turns the cell red??


In that case you just insert the FormatConditions property like:

Sub cntclr()
Count = 0
For Each C In Worksheets(1).Range("A1:F20") 'Change range for needs.
If C.FormatConditions.Interior.ColorIndex = 3 Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top