function not producing cents, only whole dollars

F

Frank Kabel

Hi Jim

you have defined the return value as 'Long' and therefore
excel has rounded the result. Try:

Function SumByColor(CellColor As Integer, SumRange As
Range)
Dim mycell As Range
Dim myTotal
For Each mycell In SumRange
If mycell.Interior.ColorIndex = CellColor Then
if isnumeric(mycell.value)
myTotal = mycell.value + myTotal
end if
End If
Next mycell
SumByColor = myTotal
End Function
-----Original Message-----
The below function is working great, only it is producing
my sum in whole dollars not with dollars and cents.
example 123.11 + 125.11 = $248.00
 
J

Jim May

Thanks Frank,
Jim May

Frank Kabel said:
Hi Jim

you have defined the return value as 'Long' and therefore
excel has rounded the result. Try:

Function SumByColor(CellColor As Integer, SumRange As
Range)
Dim mycell As Range
Dim myTotal
For Each mycell In SumRange
If mycell.Interior.ColorIndex = CellColor Then
if isnumeric(mycell.value)
myTotal = mycell.value + myTotal
end if
End If
Next mycell
SumByColor = myTotal
End Function

my sum in whole dollars not with dollars and cents.
example 123.11 + 125.11 = $248.00
 
Top