View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Logical comparison not working in VBA ????

You are seeing roundoff error. The variable never hits .085 exactly.
--
Gary''s Student - gsnu200794


"VTengineer" wrote:

Pasted below is an excerpt from VBA code I'm working on. For some reason it
will not properly execute this logic. When StopLong = 0.085 it cannot make
the first If..then logical comparison. Passes right over it. Have been using
VBA for 10years and have no clue whats going on.

For BuyLim = 0.001 To 0.07 Step 0.002
For GainSell = 0.001 To 0.08 Step 0.003
For StopLong = 0.001 To 0.09 Step 0.003

If StopLong = 0.085 Then
If GainSell = 0.001 Then
If BuyLim = 0.001 Then
weird = False
End If
End If
End If

Next
Next
Next