typo:
Dim r as Range, dblSum as Double
For Each r In Range("A1:B100")
If r.Interior.ColorIndex = 6 Then
if isnumeric(r) then
dblSum = dblsum + r
end if
Next
--
Regards,
Tom Ogilvy
"Tom Ogilvy" wrote in message
...
It counts the number of cells that are red. If you want to sum them then
Dim r as Range, dblSum as Double
For Each r In Range("A1:B100")
If r.Interior.ColorIndex = 6 Then
if isnumeric(r) then
dblSum = dlbsum + r
end if
Next
However, since you are getting 0 for the count, I suspect your red color
is
being produced by conditional formatting. Unfortunately, there isn't an
easy way to check what color is being produced by conditional formatting
(colorindex won't tell you that). In that case, you would need to check
the
condition used by the conditional formatting. What is the condition for
summing? (if that is the case).
--
Regards,
Tom Ogilvy
"havocdragon" wrote in message
...
This keeps returning the value of 0. Yes I have several of my lines red.
But
correct me if I am wrong, but this would just sum the amount of cells
that
are red, not the values in them correct?
Also I use a variable range
"kkknie" wrote:
How about this:
Dim r As Range
Dim iCount as Long
iCount = 0
For Each r In Range("A1:B100")
If r.Interior.ColorIndex = 6 Then iCount = iCount + 1
Next
MsgBox iCount
Using your range for the A1:B100 entry.
K
--
kkknie
------------------------------------------------------------------------
kkknie's Profile:
http://www.excelforum.com/member.php...fo&userid=7543
View this thread:
http://www.excelforum.com/showthread...hreadid=268949