function not producing cents, only whole dollars

  • Thread starter Thread starter Frank Kabel
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top