sum the color cells
Howard...
i already try, copy your code then paste in module...
but there were a bug in
Run-time error '1004':
method 'Range' of object'_Global' failed
when i click debug, it will go to:
For Each Cell In Range("Data")
thanks
"L. Howard Kittle" wrote:
Give this a try. Copy and right click on the sheet tab and paste in the
sheet module. Provides a summation list in F10, F11 & F12 along with a
Message Bos of the results.
Probably want to try on a test worksheet first.
Sums the values of all Blue, Red and Yellow formatted cells in A1:A1000.
Will not work on conditional formatted cells.
If you are trying to sum the colors of the FONTS of each cell in A:A then
post back. That is quite possible also.
Sub SumColorCount()
Dim Blue5 As Integer, _
Red3 As Integer, _
Yellow6 As Integer
Dim Data As Range
Dim Cell As Range
Set Data = Range("A1:A1000")
For Each Cell In Range("Data")
If Cell.Interior.ColorIndex = 5 Then
Blue5 = Blue5 + Cell.Value
ElseIf Cell.Interior.ColorIndex = 3 Then
Red3 = Red3 + Cell.Value
ElseIf Cell.Interior.ColorIndex = 6 Then
Yellow6 = Yellow6 + Cell.Value
End If
Next
Range("F10").Value = "Blue = " & Blue5
Range("F11").Value = "Red = " & Red3
Range("F12").Value = "Yellow = " & Yellow6
MsgBox " You have: " & vbCr _
& vbCr & " Blue " & Blue5 _
& vbCr & " Red " & Red3 _
& vbCr & " Yellow " & Yellow6, _
vbOKOnly, "CountColor"
Range("F10:F12").Value = ""
End Sub
HTH
Regards,
Howard
"reza" wrote in message
...
hi all.
i have data with different color.
i one column i have 3 color, blue, yellow and red.
now i want to count & sum based on the colors.
how to create formula for that?
many thanks...
reza
.
|