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.
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

zzdave

New Member
Joined
May 21, 2002
Messages
13
Yeah I'm sure it is but you may have to write your own function in VB to do it.
 

eliW

Well-known Member
Joined
Mar 2, 2002
Messages
1,931
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,143
Messages
5,599,975
Members
414,354
Latest member
Flaxarn

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
Top