user4095324
user4095324

Reputation: 13

Compare value of cell in vba

I am trying to compare the value of a cell (always a number) to the iteration variable in a for loop but for some reason vba says this is an invalid call or argument. I am new to vba so any help would be greatly appreciated.

For i = 2 To wb1.Sheets("Development Priority List").Rows.Count

If wb1.Sheets("Development Priority List").Cells("A" & i).Value < i - 1 Then
    wb1.Sheets("Development Priority List").Range("A" & i, "Z" & i).Delete
End If

Next i

Upvotes: 1

Views: 729

Answers (1)

Mr. Mascaro
Mr. Mascaro

Reputation: 2733

Your IF statement is incorrect. Change to:

If wb1.Sheets("Development Priority List").Cells(i,1).Value < i - 1 Then

Upvotes: 2

Related Questions