title: run loop step on decimal on vba get stuck
body: <p>Here is my code to solve interest rate on vba, but the loop will run to the death!</p>
  
  <p>Please help me to find what the problem is on the code!</p>
  
  <p>Thank you very much!!!</p>
  
  <pre><code>Sub rate()
  
      Dim r As Long
      Dim y As Long
      Dim term0 As Long
      Dim term1 As Long
      Dim term2 As Long
      Dim term3 As Long
      Dim term4 As Long
  
      For r = 0.05 To 0.08 Step 0.001
          term0 = 10000
          term1 = 14000 / (1 + r)
          term2 = 18000 / (1 + r) ^ 2
          term3 = 22000 / (1 + r) ^ 3
          term4 = 25000 / (1 + r) ^ 4
  
          y = term0 + term1 + term2 + term3 + term4
          If y &lt;= 75000 Then
              MsgBox (r)
          End If
      Next r
  
  End Sub
  </code></pre>
  
  <p>Thank you simoco and  Enigmativity!</p>
  
  <p>After revision, here is the code which works great!</p>
  
  <pre><code>Sub rate()
  
      Dim r As Double
      Dim y As Long
      Dim term0, term1, term2, term3, term4 As Long
  
      r = 0.06
      Do
          r = r + 0.00001
          term0 = 10000
          term1 = 14000 / (1 + r)
          term2 = 18000 / (1 + r) ^ 2
          term3 = 22000 / (1 + r) ^ 3
          term4 = 25000 / (1 + r) ^ 4
  
          y = term0 + term1 + term2 + term3 + term4
  
      Loop Until y &lt;= 75000
  
      Cells(11, 11) = r
      Cells(14, 12) = term0
      Cells(15, 12) = term1
      Cells(16, 12) = term2
      Cells(17, 12) = term3
      Cells(18, 12) = term4
      Cells(20, 12) = y
  
  End Sub
  </code></pre>