I'm trying to skip to the next iteration in my vba code, with the 'continue' statement. Its not working..
  Do Until IsEmpty(xlSheet.Cells(row, 1))
       row = row + 1
       If xlSheet.Cells(row, 2) = "Epic" Then
          Continue
       End If
       xlSheet.Cells(row, 1).Value = 5
  Loop
Any idea?? Thanks..
VBA does not have a Continue statement.  You can get around it by doing something like
Do Until IsEmpty(xlSheet.Cells(row + 1, 1))
   row = row + 1
   If xlSheet.Cells(row, 2) <> "Epic" Then
       xlSheet.Cells(row, 1).Value = 5
   End If
Loop
or
Do Until IsEmpty(xlSheet.Cells(row + 1, 1))
    row = row + 1
    If xlSheet.Cells(row, 2) = "Epic" Then
        GoTo ContinueDo
    End If
    xlSheet.Cells(row, 1).Value = 5
ContinueDo:
Loop
Note: In both versions I changed IsEmpty(xlSheet.Cells(row, 1)) to IsEmpty(xlSheet.Cells(row + 1, 1)) or else you will end up with an infinite loop.
So this is another possibility that works for me. Just skip the unwanted lines...
Do Until IsEmpty(xlSheet.Cells(row, 1))
   row = row + 1
   Do while xlSheet.Cells(row, 2) = "Epic" 
      row = row + 1
   Loop
   xlSheet.Cells(row, 1).Value = 5
Loop
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With