ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   color count... (https://www.excelbanter.com/excel-programming/382330-color-count.html)

okrob

color count...
 
My sub counts the color of cells in the range specified.
I'd like to count the color of cells that are colored with conditional
formating.
Right now, the entire range is set to no fill or some other color, but
upon some entry the conditional formating colors the cell red. I need
to count the red cells.
Conditionally, I have the cells in range hrdata set to red (normally
no fill) and this sub doesn't count them.
I need an explaination, please?

Sub ColorCount()
red = 0
For Each Cell In Sheet2.Range("hrdata")
If Cell.Interior.ColorIndex = 3 Then
red = red + 1
Else
End If
Next
if red 0 then
MsgBox red
Else
End If
End Sub

Thanks,
Rob


Bob Phillips

color count...
 
Read this article http://xldynamic.com/source/xld.CFConditions.html

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"okrob" wrote in message
oups.com...
My sub counts the color of cells in the range specified.
I'd like to count the color of cells that are colored with conditional
formating.
Right now, the entire range is set to no fill or some other color, but
upon some entry the conditional formating colors the cell red. I need
to count the red cells.
Conditionally, I have the cells in range hrdata set to red (normally
no fill) and this sub doesn't count them.
I need an explaination, please?

Sub ColorCount()
red = 0
For Each Cell In Sheet2.Range("hrdata")
If Cell.Interior.ColorIndex = 3 Then
red = red + 1
Else
End If
Next
if red 0 then
MsgBox red
Else
End If
End Sub

Thanks,
Rob




okrob

color count...
 
yeah, I got some of the same info from Chip Pearson's site. I decided
I was going about this all wrong and just did the test with vb like I
did for the conditional format and counted that up. It produced the
same results.
Rob



All times are GMT +1. The time now is 06:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com