SumByColor Macro...
As stated by several people in response to your post, a color change does
not cause a recalculation to occur. (Excel does not inherently support
color as a discriminator in any type of calculation).
--
Regards,
Tom Ogilvy
"Murph" wrote in message
...
Norman -
I checked that and it is selected currently.
I assume this basically has something to do with Excel not recognizing
colors as part of a formula argument. If I click in another cell and just
type in 0 and hit enter it then recalculates and finds the 'red' and
'black'
entries. Just seems odd - and of course not as user friendly as I would
like.
Also if I delete an entry in the cell it automatically recalculates. So
basically the problem happens when I take the cell font color from black
to
red.
Thanks for the help.
"Norman Jones" wrote:
Hi Murph,
Try:
Tools | Options | Calculation | check 'Automatic'
---
Regards,
Norman
"Murph" wrote in message
...
I am using the following Macro - the formula I use to access the macro
is
=sumBYCOLOR(C13:H22,3,TRUE)
The problem I am having is that the formula does not automatically
calculate
no information inputted into the excel sheet. I have to go to the cell
with
the formula and place my cursor at the end of the formula and hit
enter
for
it to adjust with the new information. Any help?
Macro is:Function SumByColor(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 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 OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng
End Function
|