lundi 27 juin 2016

VBA Skipping Lines of Code

I have a part of a macro that is being completely skipped when it is executing. I think I probably has something to do with the if statement combined with the loop.

For x = 1 To HomeLoop
    If Application.WorksheetFunction.CountIf(Sheet6.Range("G:G"), Sheets(1).Cells(x + 2, 1)) = 0 Then
        Sheets(1).Select
        Rows(x + 2).Select
        Selection.Delete Shift:=xlUp
    Else
    End If
Next x

There is more code before and after the block. When I'm going through the code with the debugger, the "For x = 1 to HomeLoop" will highlight and the next step goes directly to highlight the code below the "Next x" I can't figure out why the block is being completely skipped.

Any help is greatly appreciated.

Thank you.

Aucun commentaire:

Enregistrer un commentaire