Conditional inside for loop affects loop variable increment

Not sure what you’re attempting to do, but this seems more like what you’re after:

Dim sects As Variant, i As Integer, N As Integer, m As Integer

sects = Array(0, 3, 9, 14, 26, 29)
N = 30
For i = 1 To N
  For m = 0 To UBound(sects)
    MsgBox "i, m = " & i & ", " & m
    If i > sects(m) Then
      MsgBox "i > sects(m) = " & i & ", " & sects(m) & ", " & m
    End If
  Next m
Next i

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top