I have a list of values and want to add the ones up that I change the font color on. I am having trouble with the user function on recalculating. The only time it works is when I select the formula in the cell and hit enter. Here's what I have
Function SumFontColor(rng As Range, iColor As Integer) As Double
Dim rngAct As Range
Dim dAdd As Double
For Each rngAct In rng.Cells
If IsNumeric(rngAct.Value) Then
If rngAct.Font.ColorIndex = iColor Then
dAdd = dAdd + rngAct.Value
End If
End If
Next rngAct
SumFontColor = dAdd
End Function
as the user function in cell c75
I tried this
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells("c75").Calculate
End Sub
on the worksheet module but it does not seem to help.
Function SumFontColor(rng As Range, iColor As Integer) As Double
Dim rngAct As Range
Dim dAdd As Double
For Each rngAct In rng.Cells
If IsNumeric(rngAct.Value) Then
If rngAct.Font.ColorIndex = iColor Then
dAdd = dAdd + rngAct.Value
End If
End If
Next rngAct
SumFontColor = dAdd
End Function
as the user function in cell c75
I tried this
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells("c75").Calculate
End Sub
on the worksheet module but it does not seem to help.