Code Not Recognizing Decimal
PS....
"Ron" wrote:
My goal is to have the column equal Zero or,
at least within a penny, but I'm getting this
instead -0.00000000006984990.
Although simply rounding the sum might mask this particular abberation, it
would be prudent to use ROUND liberally in most financial calculations in
the Excel spreadsheet as well. That will minimize propagating such
numerical abberations into other spreadsheet calculations. Even formulas as
innocuous as =A1-A2 can introduce annoying numerical abberations.
----- original message -----
"JoeU2004" wrote in message
...
"Ron" wrote:
I've tried Rounding with no results.
My goal is to have the column equal Zero or,
at least within a penny, but I'm getting this
instead -0.00000000006984990.
My response to your original inquiry anticipated this. Have a look at it.
But you say that rounding did not remedy the problem. It certainly should
have.
If my previous posting does not answer your question, please post your
rounding code, including all relevant declarations.
----- original message -----
"Ron" wrote in message
...
Hi Peter, You were spot on with the SumRng as Double. But I'm having
a little problem getting my code to work properly. For some reason
there are trailing decimals that I am told are binary values. How do
I deal with them? I've tried Rounding with no results. My goal is to
have the column equal Zero or, at least within a penny, but I'm
getting this instead -0.00000000006984990. After changing SumRng to
double I get something like this in the MSGBOX-6.984990. I think my
problem is the binary values. Thanks for your assistance, Ron
On Jul 27, 3:30 pm, "Peter T" <peter_t@discussions wrote:
Did you declare SumRng As Long. Try -
Dim SumRng as Double
The # after a value tells the compiler to treat it as a Double, rather
than
as an Integer in the case of a non decimal.
Regards,
Peter T
"Ron" wrote in message
...
Hello all,
Anyone have any ideas why this code does not recognize the decimal.
I'm trying to test a column to make sure it equals zero. However for
some reason this code does not recognize the trailing decimals. When
I change IF SUMRNG < 0 then to IF SUMRNG < 0.00 VBA alters it to
0#. If the column is out of balance .49 cents it does not activate
the MSGBOX but if it's out .50 cents then the MSGBOX is activated.
Appreciate your assistance, Ron
With Selection
SumRng = Application.WorksheetFunction.Sum(Selection)
If SumRng < 0 Then
MsgBox "Out of Balance, Please review and make the necessary
corrections. Balance should equal ZERO. " & SumRng
End If
End With- Hide quoted text -
- Show quoted text -
|