M
Murph
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
=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