If field in column is blank, delete if....

C

CPower

Hi all,

I have a macro statement that, if a field in a certain column is blan
it will look to another column in the same row, and if that fiel
contains a certain name it will delete the entire row. I want
statement that will NOT delete the row if it contains a certain name
i.e. if any field in col E is blank look to col D and delete the entir
row if it does not contain Mark, Brian and Karl.

Can anyone please help me on this??

Thanks in advance,

Cathal
 
D

Dave Peterson

I _think_ that this does what you want:

Option Explicit
Sub testme02()

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
If IsEmpty(.Cells(iRow, "e")) Then
Select Case LCase(.Cells(iRow, "D").Value)
Case Is = "mark", "brian", "karl"
'do nothing
Case Else
.Rows(iRow).Delete
End Select
End If
Next iRow
End With

End Sub

I did use column D to find the last row.
 
Top