![]() |
Count Red Cells on a worksheet
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! |
Count Red Cells on a worksheet
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 "Aaron" wrote: 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! |
Count Red Cells on a worksheet
You realize, of course, that is not complete code.
"Aaron" wrote: 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! |
Count Red Cells on a worksheet
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" wrote: 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! |
Count Red Cells on a worksheet
What if it is a conditional formatting that turns the cell red??
"JLGWhiz" wrote: 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" wrote: 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! |
Count Red Cells on a worksheet
"Aaron" wrote: 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 "JLGWhiz" wrote: 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" wrote: 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! |
All times are GMT +1. The time now is 10:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com