View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Code Not Recognizing Decimal

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