View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
pshepard[_2_] pshepard[_2_] is offline
external usenet poster
 
Posts: 55
Default Sum Column Based on Cell Color

Hi Thomas,

If you create the following User Defined Function (UDF), by entering Alt + F11

paste the following code into a Module:

Function Color(cell)
Color = cell.Interior.Color
End Function

Column with colored cells A2:A100, insert a helper column into column B,
then in cell B2:

=color(A2)

copy the formula from B2 to B3:B100.

=sumif(B2:B100,B2,A2:A100)

note, the color number for Red 153, Green 204, Blue 0 is 52377

so your formula could be:
=sumif(B2:B100,52377,A2:A100)

OR

You can also use the autofilter to filter by color. When data is filtered,
then you can use the subtotal worksheet function:

=SUBTOTAL(9,A:A)

--
If this post helps click Yes
---------------
Peggy Shepard


"Thomas M." wrote:

Excel 2007

Is there a way to sum a column of numbers based on the background color of
the cells? For example, I have a column that contains gold, blue, and green
cells, and I want to sum only the green cells. The color definition is:

Red 153
Green 204
Blue 0


--
Thanks for any help that you can offer!

--Tom