Hi,
Im still new in VBA.
I tried to do the next iteration in the "nested for..next loop". Here is my attempt in doing it. But there's an error

Compiler complains : Invalid Next control variable reference

Could anyone help me with this?

Thanks in advance.


For i = 4 To 34
        If (Sheet2.Cells(i, 18) < Date) Then
            a = 1
            For j = 1 To count
                DueArray(j, 0) = Sheet2.Cells(i, 7)
                DueArray(j, 1) = Sheet2.Cells(i, 3)
                DueArray(j, 2) = Sheet2.Cells(i, 18)
    
                b = 1
                
                If b = 1 Then
                    GoTo endloop
                End If
                
                If a = 1 And b = 0 Then
                    GoTo endLoop2
                End If
        
endloop:
    a = 0
    b = 0
    Next i
endLoop2:
    Next j
    
        End If