Good afternoon,
I have a problem with a VBA function to sum cells based on background color. I got the function from a site calle trumpexcell, this is it:
'Code created by Sumit Bansal - (Not posting the link because im a new member)
'This VBA code created a function that can be used to sum cells based on color
Function SumByColor(SumRange As Range, SumColor As Range)
Dim SumColorValue As Integer
Dim TotalSum As Long
SumColorValue = SumColor.Interior.ColorIndex
Set rCell = SumRange
For Each rCell In SumRange
If rCell.Interior.ColorIndex = SumColorValue Then
TotalSum = TotalSum + rCell.Value
End If
Next rCell
SumByColor = TotalSum
End Function
In my case one sum is giving 39,999.00 but the three cells it is counting have 13,333.33+18,683.33+7,983.34 and it sums 40,000.00 if i do normally
Why is it behaving like this and what should I do for it?
Appreciate for the help and sorry that english is not my first language
Best regards,
Bookmarks