Hi

I have written a loop-code but I get this message "Loop without Do". Now I have checked the code and i cant find whats wrong with it. Theres only one loop in the code so I cant see why the program doesnt recognise the first "Do" statement.

This is the code (somewhat shortened though)

VB Code:
  1. For i = 1 To iEnd
  2.    
  3.         bordervalue = 0.001
  4.        
  5.         bX1temp = ws.Cells(i, "a").Value
  6.         bX2temp = ws.Cells(i, "d").Value
  7.         bY1temp = ws.Cells(i, "b").Value
  8.         bY2temp = ws.Cells(i, "e").Value
  9.  
  10.         Do
  11.    
  12.             bEnough = True
  13.            
  14.             bXMtemp = (bX1temp + bX2temp) / 2
  15.             bYMtemp = (bY1temp + bY2temp) / 2
  16.            
  17.  
  18.             If bXMtemp < dXMin Then
  19.                 If 0 > Me.txtP1X.Value > bXMtemp Then
  20.                     bP1xxM = dP1 * (bXMtemp - Me.txtP1X.Value)
  21.                 End If
  22.                 If 0 > Me.txtP2X.Value > bXMtemp Then
  23.                     bP2xxM = dP2 * (bXMtemp - Me.txtP2X.Value)
  24.                 End If
  25.                 If 0 > Me.txtP3X.Value > bXMtemp Then
  26.                     bP3xxM = dP3 * (bXMtemp - Me.txtP3X.Value)
  27.                 End If
  28.                 If 0 > Me.txtP4X.Value > bXMtemp Then
  29.                     bP4xxM = dP4 * (bXMtemp - Me.txtP4X.Value)
  30.                 End If
  31.                 If 0 > Me.txtP5X.Value > bXMtemp Then
  32.                     bP5xxM = dP5 * (bXMtemp - Me.txtP5X.Value)
  33.                 End If
  34.                 If 0 > Me.txtP6X.Value > bXMtemp Then
  35.                     bP6xxM = dP6 * (bXMtemp - Me.txtP6X.Value)
  36.                 End If
  37.             End If
  38.                        
  39.          [B] [CUT OUT CODE]....[/B]        
  40.            
  41.             bPxxSum = bP1xxM + bP2xxM + bP3xxM + bP4xxM + bP5xxM + bP6xxM
  42.            
  43.             dY = 1 / dH * (dRa * bXMtemp - bPxxSum) + dYStrt
  44.             dX = bXMtemp
  45.            
  46.             If Not bYMtemp - dY < bordervalue Then
  47.                 bEnough = False
  48.                 If dY < bYMtemp Then
  49.                     bX2temp = bXMtemp
  50.                     bY2temp = bYMtemp
  51.                 End If
  52.                 If dY > bYMtemp Then
  53.                     bX1temp = bXMtemp
  54.                     bY1temp = bYMtemp
  55.                 End If
  56.             End If
  57.            
  58.         Loop While Not bEnough
  59.            
  60.         ws.Cells(i, "G").Value = dX
  61.         ws.Cells(i, "H").Value = dY
  62.        
  63.     Next i

Does anyone have any idea to whats wrong?

Could it be that the loopcode is to long? are there any restrictions to that?