sum of only green cells

J

Jan Caesar

How do I sum e.g. only green cells in my worksheet, when I color the cells in
two different colors, green and red?
 
D

Don Guillett

try
Sub addcolorcells()
For Each c In Selection
If c.Interior.ColorIndex = 4 Then ms = ms + c
Next
MsgBox ms
End Sub
 
G

Gord Dibben

Jan

Depends on how the cells became colored.

If by using Conditional Formatting, count using the same conditions.

If not by CF you will need VBA code to count by color. See Chip Pearson's
site at

http://www.cpearson.com/excel/colors.htm

Gord Dibben Excel MVP

On Mon, 6 Sep 2004 11:51:02 -0700, "Jan Caesar" <Jan
 
Top