Conditional Statements With Different Color cells

ant

New Member
Joined
May 9, 2002
Messages
8
(I'm not sure if this posted, so I'll try again)

Is it possible to create conditional statements based on the color of a cell:

I would like to sum a column but omit the cells that I decide to put in yellow (or any chosen color).

Thanks!

ant.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
On 2002-11-06 06:43, ant wrote:
(I'm not sure if this posted, so I'll try again)

Is it possible to create conditional statements based on the color of a cell:

I would like to sum a column but omit the cells that I decide to put in yellow (or any chosen color).

Thanks!

ant.
Hi ant,
Try this UDF code, I found it in: http://www.cpearson.com/excel/colors.htm
and modified it to your need.<font size=-1> Function SumMinusColor(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 minus 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 Not OK And IsNumeric(Rng.Value) Then
SumMinusColor = SumMinusColor + Rng.Value
End If
Next Rng

End Function</font size>

The ColorIndex for Yellow is 6.

Regards,

Eli
This message was edited by eliW on 2002-11-06 17:05
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,401
Members
448,893
Latest member
AtariBaby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top