To Sum the values of the blue cells use this UDF.
Note: both the countbycolor and sumbycolor functions are from Chip
Pearson's site
http://www.cpearson.com/excel/topic.aspx
Function SumByColor(InRange As Range, SameColorAs As Range, _
Optional OfText As Boolean = False) As Double
Dim WhatColorIndex As Integer
If OfText = True Then
WhatColorIndex = SameColorAs(1).Font.ColorIndex
Else
WhatColorIndex = SameColorAs(1).Interior.ColorIndex
End If
If OK And IsNumeric(rng.Value) Then
SumByColor = SumByColor + rng.Value
End If
Next rng
End Function
To get a list of the index numbers for colors run this macro.
Sub ListColorIndexes()
Dim Ndx As Long
Sheets.Add
For Ndx = 1 To 56
Cells(Ndx, 1).Interior.ColorIndex = Ndx
Cells(Ndx, 2).Value = Hex(ThisWorkbook.Colors(Ndx))
Cells(Ndx, 3).Value = Ndx
Next Ndx
End Sub
On Sun, 12 Apr 2009 05:01:01 -0700, Michele R
wrote:
Hi
thanks for that, it looks do-able! Would there be a similar simple way of
adding the values in all the blue cells and the values of the red cells?
And are there number codes for other colours, and how could I know what they
are?
Thanks for your help.