2016-04-19 12 views
0

Wir sind in einer Schleife stecken und können es nicht weiter Werte ziehen. Dieser Code wird nur den ersten Wert ziehen und Schleifen beibehalten.Warum läuft dieser Code weiter?

Sub createpbp() 

    Dim iRows As Integer 
    Dim i As Integer 'webtext row counter 
    Dim iR As Integer 
    Dim iPr As Integer 'row counter for pbp worksheet 
    Dim wksWT As Worksheet 


    iPr = 1 

    Set wksWT = Worksheets("Webtext") 'creating a variable for the text pulled from website 

    wksWT.Activate 'activate the webtext sheet 

    iRows = wksWT.UsedRange.rows.Count 'counts rows in the play by play 

    For i = 1 To iRows 'row 1 to end of rows 
     If Cells(i, 1) = "Play By Play Innings" Then 'if the cell value says play by play innings 
      Do Until Cells(i, 1) = "Runs" 'continue doing the following until reach end of inning 
       Cells(i, 1).Copy 'copy the value of the first event in inning 
       Sheets("Play by Play text").Select 'open up new worksheet 
       If Cells(iPr, 1) = Null Then 
        Cells(iPr, 1).Paste 
       Else 
        iPr = iPr + 1 
       End If 
      Loop 
     End If 
    Next i 
+1

Betrachten Sie bis Zellen (i, 1) = "Läuft" ... wenn Zellen (i, 1) <> "Läuft", wird diese Schleife für immer ausgeführt, da nichts in dieser Schleife ändert i – oortCloud

Antwort

1

Etwas stimmt nicht mit Ihrer Schleife.

Ich sehe nirgendwo in Ihrer Schleife, die den Wert dieser Zelle in "Läuft" ändert. Und ich sehe nirgendwo in Ihrer Schleife, dass der Wert von i erhöht.