summing by color
sorry that i wasn't clear. here is the function
Function SumByColor(InRange As Range, WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Double
'
' This function return the SUM of the values of cells in
' InRange with a background color, or if OfText is True a
' font color, equal to WhatColorIndex.
'
Dim Rng As Range
Dim OK As Boolean
Application.Volatile True
For Each Rng In InRange.Cells
If OfText = True Then
OK = (Rng.Font.ColorIndex = WhatColorIndex)
Else
OK = (Rng.Interior.ColorIndex = WhatColorIndex)
End If
If OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng
End Function
--
aprilshowers
"FSt1" wrote:
hi
there are 10 different function on that page not counting "other function".
please post the one you are using.
Regards
FSt1
"april" wrote:
i have copied the code from cpearson.com/excel/colors.htm which allows you to
sum a range of cells by color. this worked fine in one spreadsheet but when
i copied the same code to another spreadsheet i get a NAME? error. any
suggestions?
thank you
--
aprilshowers
|