On 2002-04-17 21:24, Jay Petrulis wrote:
Hi,
I have posted a UDF which is *not* working and a subroutine which is essentially identical and does work.
I have no idea why the UDF isn't working. Possibly others will have an answer, but this might get you started.
---------------------
Function SumColor(Rng As Range, textcolor As Integer)
Dim UsedCell As Range, MySum As Double
For Each UsedCell In Rng
If IsNumeric(UsedCell.Value) Then
If UsedCell.Font.ColorIndex = textcolor Then
MySum = MySum + UsedCell.Value
End If
End If
Next UsedCell
End Function
Sub Sumclr()
textcolor = 3
For Each Cell In Selection
If IsNumeric(Cell.Value) Then
If Cell.Font.ColorIndex = textcolor Then
MySum = MySum + Cell.Value
End If
End If
Next Cell
MsgBox MySum
End Sub
----------------------------
Regards,
Jay