From: Mr. Low Mr. on
Hi,

I understand that Excel 2007 can sort by colors. It is a great feature indeed.

May I know if =SUMIF( ) could use a color as the condition to sum up color
shaded cells or cells with certain font color?

Thanks

Low
From: מיכאל (מיקי) אבידן on
If I understood you correctly - you can type' into a Module, a small User
Defined Function - such as:
--------------------------------------
Function IntColor(Rng As Range)
Application.Volatile
IntColor = Rng.Interior.ColorIndex
End Function
add
-----------
Assuming your list is in range A1:A10 - in B1 type: =IntColor(A1)+NOW()*0
and copy down to B10 to get the ColorIndex in Range B1:B10..
Now, you can SUM the values according to the ColorIndex.
Micky


"Mr. Low" wrote:

> Hi,
>
> I understand that Excel 2007 can sort by colors. It is a great feature indeed.
>
> May I know if =SUMIF( ) could use a color as the condition to sum up color
> shaded cells or cells with certain font color?
>
> Thanks
>
> Low
From: Jacob Skaria on
There is no built-in excel function to do this. But you can use a UDF that
looks at the range and returns the sum of color. But that function will not
recalculate if you change color. Every time you change the color you will
need to recalculate or wait excel to recalculate...

To install the UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

A1:A10 is the range to be checked. B1 is a lookup cell coloured ..
=colorsum(A1:A10,B1)
=colorcount(A1:A10,B1)

'function to sum values within colorred cells
Function ColorSum(varRange As Range, varColor As Range) As Variant
Dim varTemp As Variant, cell As Range
ColorSum = 0
For Each cell In varRange
If cell.Interior.ColorIndex = varColor.Interior.ColorIndex Then
If IsNumeric(cell.Value) Then ColorSum = ColorSum + cell.Value
End If
Next
End Function

'Function to count the colored cells (not colored through Conditional
formatting)
Function ColorCount(varRange As Range, varColor As Range) As Variant
Dim varTemp As Variant, cell As Range
ColorCount = 0
For Each cell In varRange
If cell.Interior.ColorIndex = varColor.Interior.ColorIndex Then
ColorCount = ColorCount + 1
End If
Next
End Function

--
Jacob


"Mr. Low" wrote:

> Hi,
>
> I understand that Excel 2007 can sort by colors. It is a great feature indeed.
>
> May I know if =SUMIF( ) could use a color as the condition to sum up color
> shaded cells or cells with certain font color?
>
> Thanks
>
> Low
From: Valy Greavu on
You cannot do a native sumif by colors.
You must create a VBA function for that.

Take a look here:

Function SumCuloare(Culoare As Range, Casute As Range)

'Definirea variabilelor
Dim rrRange As Range
Dim sumColor As Long
Dim rrCasute As Range

'Definirea constantelor
sumColor = 0
Set rrCasute = Casute
vCuloare = Culoare.Font.Color

' Suma pe culori
For Each rrRange In rrCasute
If rrRange.Font.Color = vCuloare Then
sumColor = sumColor + rrRange.Cells.Value
End If
Next rrRange

' Returnare rezultat
SumCuloare = sumColor

End Function


You can see a sample on my blog:
http://valygreavu.wordpress.com/2010/01/08/stupid-work-procedures-beautiful-solutions/

--
Valy Greavu
MCP, MOS Expert


"Mr. Low" wrote:

> Hi,
>
> I understand that Excel 2007 can sort by colors. It is a great feature indeed.
>
> May I know if =SUMIF( ) could use a color as the condition to sum up color
> shaded cells or cells with certain font color?
>
> Thanks
>
> Low
From: Valy Greavu on
Try this:
http://valygreavu.wordpress.com/2010/01/08/stupid-work-procedures-beautiful-solutions/

--
Valy Greavu
MCP, MOS Expert


"Mr. Low" wrote:

> Hi,
>
> I understand that Excel 2007 can sort by colors. It is a great feature indeed.
>
> May I know if =SUMIF( ) could use a color as the condition to sum up color
> shaded cells or cells with certain font color?
>
> Thanks
>
> Low