OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Hello and thanks in advance for your help and if it works, I will provide feedback.
I'm trying to delete the rows if the value in the cell in Column B is equal to delete, but I'm getting an error on
" If Cells(i, 2).Value = "Delete" Then Cells(i, 2).EntireRow.Delete"
Here is the code.
I'm trying to delete the rows if the value in the cell in Column B is equal to delete, but I'm getting an error on
" If Cells(i, 2).Value = "Delete" Then Cells(i, 2).EntireRow.Delete"
Here is the code.
Code:
Sub DeleteRow()
Dim i As Integer
Dim LastRow2 As Long
LastRow2 = Cells.Find(What:="*", _
after:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
For i = LastRow2 To 1 Step -1
If Cells(i, 2).Value = "delete" Then Cells(i, 2).EntireRow.Delete
Next i
End Sub()