View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default Does Excel have a counting glitch? or is it more likely me?

"The value it created itself" - yes, that is the problem. Computers don't
create decimal numbers. Everything has to be converted from binary and that
is why typing of a variable can be critical. When you are testing
non-integer variables for exact matches you will always need to beware and
give your code some leeway to deal with floating point/rounding errors.
--
- K Dales


"Ron" wrote:

Thanks George (& Don)


I know there are a few ways to do what I'm trying, this isn't why I
posted or what I want to know.

If we start with the variable myFigure at 1.05. The code runs and the
code generates the new myFigure variable. There is no input from
outside whatsoever during run time in this piece of code.

If the code, and only the code, generates the myFigure variable and then
places it in a cell, why cant it find it's own product in the next
instance of the loop?

It generates, and then subsequently finds it's own product upto and
including 1.12 but it then generates 1.13 and plonks the value in the
relevant cell. But here's my beef......why can't it look for and find
the value it has just created itself? regardless of absolute values or
decimal places?

Can anyone answer this?


Ron




















"George Nicholson" wrote in
:


You might try:
Do Until Round(ActiveCell.Value,2) = myFigure
just in case your worksheet values have precision beyond what is being
displayed, thereby "not matching" myFigure.

or, rather than going for a 100% exact match, maybe go for "close
enough". Something like
Do Until abs(ActiveCell.Value - myFigure) =< 0.01

HTH,