title: Compile error: Next without For || VBA
body: <p>I have a problem with my code, an error appears, and I don;t understand why. The error is:<br>
  "Compile error: Next without For"<br>
  I do not understand why it is like that. I am new to coding so any help and comments are more than welcome.<br>
  This is the code, the Next which is pointed as the one without For is provided a comment.  </p>
  
  <pre><code>Sub CGT_Cost()
  startrow = Worksheets("GUTS").Cells(10, 1) 'Here I put 1
  endrow = Worksheets("GUTS").Cells(11, 1)   'Here I put 1000
  
  For x = endrow To startrow Step -1
  
  If Cells(x, "Q").Value = "Sale" Then
  
      If Cells(x, "D").Value = "1" Then
  
      For i = 1 To 1000
  
          If Cells(x - i, "R").Value &lt;&gt; "1" Then
  
      Next i
          Else
          Range("G" &amp; x).FormulaR1C1 = "=R[-" &amp; i &amp; "]C/R[-" &amp; i &amp; "]C[-1]*RC[-1]"
  
          End If
      End If
      End If
  Next x  
  
  End Sub  
  </code></pre>
  
  <p>Thank you all in advance,
  with best regards,<br>
  Artur.</p>