can anyone please advise me on what I am doing wrong with this procedure? It should delete about 6 rows in my file, but when I run it, no effect. In about 6 rows, there is no data in columns B and C, their position is dynamic and I want to get rid of those rows.
Thank you
Dim lastrow As Integer
lastrow = Application.WorksheetFunction.CountA(ThisWorkbook.Sheets("ISSUES").Range("D1:D5000"))
For i = 1 To lastrow
If IsEmpty(ThisWorkbook.Sheets("ISSUES").Cells(i, 2)) = True And IsEmpty(ThisWorkbook.Sheets("ISSUES").Cells(i, 3)) = True Then
ThisWorkbook.Sheets("ISSUES").Cells(i, 2).EntireRow.Delete
End If
Next i
For i = lastrow To 1 Step -1lastrowis greater than zero, and that the "no data in columns B and C" cells are actually empty, as opposed to e.g. containing a formula, a blank string or being formatted to visually hide the value.=Trueportion for yourIfstatements. They aren't needed.ThisWorkbook.Sheets("ISSUES").Cells(i, 2). It's almost always the wrong test in this context, as evidenced by the OP's comment above. Test the business rule - not the variable type.