madhuchelliah
Board Regular
- Joined
- Nov 22, 2017
- Messages
- 226
- Office Version
- 2019
- Platform
- Windows
Hello all, i want to delete the entire row if last word is not equal to "OK". I have created a macro, but it is deleting all the rows in the column instead of particular rows where last word is not equal to "OK". Thank you
VBA Code:
Sub DelD()
Dim cel As Range
Dim Rng As Range
Set Rng = Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
For Each cel In Rng
If Right(cel, Len(cel) - (InStrRev(cel, " "))) <> OK Then
cel.EntireRow.Delete
End If
Next cel
End Sub