View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Udo Udo is offline
external usenet poster
 
Posts: 48
Default How to avoid rounding when comparing numbers?

Most probably the problem is the initialization of the variables. The
following piece of code gives the correct result and shows in the
local-window all the decimals which are appropriate. The numbers I used
we First = 3,4587921, Second = 3,4587919.

Dim First As Double
Dim Second As Double
Dim Result As Double

First = Cells(8, 3)
Second = Cells(8, 4)
Result = First / Second
If Result < 1 Then
MsgBox ("Not identical")
End If

Good luck
Udo

Maury Markowitz schrieb:

"Udo" wrote:

Try to simply divide the numbers. If the result is not exactly 1, then
there is a difference.


That doesn't really help. When I read the cell value, even though it clearly
has a five-decimal-place number in it, the value returned in VB is four
decimals long. In other words if I try to fix the database, it gets "fixed"
with the wrong number.

Why is it that when I refer to the cell I get a rounded number?

Maury