Condition Function

M

Mark

Is it possible to calculate the sum of a row excluding
cell that are colour hi-lighted?

If you know how to do this please let me know, thanks
 
J

JE McGimpsey

One way:

Public Function SumNoColor(ByRef rng As Range) As Variant
Dim rCell As Range
Application.Volatile True
For Each rCell In rng
With rCell
If .Interior.ColorIndex = xlColorIndexNone Then _
If IsNumeric(.Value) Then _
SumNoColor = SumNoColor + .Value
End With
Next rCell
End Function


Note that this will not automatically update when a background color is
changed. The Application.Volatile statement will recalculate the
function whenever the worksheet is recalculated (including when you type
F9).

If you're unfamiliar with UDFs, see David McRitchie's "Getting Started
with Macros and User Defined Functions":

http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top