1 Attachment(s)
help with If statement that counts
I've gotten functions just like this working before, but this one is stumping me... I'm probably doing something simple and the fix is right under my nose, but... Alas!
I have a column of data that I want to count non-blank cells that are not colored one of two shades of gray. In the attached file, all the cells I want to count are red, but that is not always the case. No matter what I try, it just counts every cell, returning a value of 93 (number of rows in the data).
Code is as follows right now:
Code:
Dim sq2d As Long
Dim r As Range, c As Range
Set r = Range("A2:A" & lastRow)
For Each c In r
If c.Interior.Color <> RGB(192, 192, 192) Or c.Interior.Color <> RGB(128, 128, 128) And Not IsEmpty(c.Value) Then sq2d = sq2d + 1
Next c
Any assistance would be greatly appreciated!
Attachment 18464