I'm trying to delete rows that have "Yes" in column B. Please help me understand why this isn't working. Thank you!
VBA Code:
Sub nocompound()
Dim ws As Worksheet
Dim lastRow As Long
Dim i, comp
Set ws = ThisWorkbook.Worksheets("rawday") 'sheet's name
lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row 'last row in column B
For i = lastRow To 2 Step -1
comp = Cells(i, "B")
If Not Empty Then 'Check if cell contains a valid date
If comp = Yes Then
ws.Cells(i, "B").EntireRow.Delete
If Empty Then
End If
End If
End If
Next i
End Sub