hvaleagues
New Member
- Joined
- Sep 25, 2009
- Messages
- 9
I have a macro that allows me to sum cells based on the shading of the cell. This works wonderfully in 2003, but when I send the file to someone using 2007 (ie my boss), the macro doesn't work and produces a ton of #NAME? errors, instead of giving him the information he needs. Here is the code:
Is there something I can change in here to make it work on 2007 (and 2010).
Any help would be greatly appreciated.
Code:
Function SumColoured(oRange As Range, lColorIndex As Variant) As Variant
Dim oCell As Range
Dim dSum As Double
Application.Volatile
For Each oCell In oRange
If oCell.Interior.ColorIndex = lColorIndex Then
dSum = dSum + Val(oCell.Value)
End If
Next
SumColoured = dSum
End Function
Any help would be greatly appreciated.