Forum Discussion

Laura_Simpson's avatar
Laura_Simpson
Copper Contributor
Mar 15, 2024
Solved

SumColor Function Rounding Up and Down Totals

Hello,

 

I am using the SumColor function with the following code.  It is rounding the sums up or down and leaving odd pence across my cash flow.  Can anyone tell me a way to stop this happening?  I popped a screen shot example below too.  Thank you.  Laura

 

Function SumColor(SumRange As Range, ColorCode As Range)
Dim ColorCodeValue As Integer
Dim TotalSum As Long
ColorCodeValue = ColorCode.Interior.ColorIndex
Set rCell = SumRange
For Each rCell In SumRange
If rCell.Interior.ColorIndex = ColorCodeValue Then
TotalSum = TotalSum + rCell.Value
End If
Next rCell
SumColor = TotalSum
End Function

 

 

Resources