Deleting rows with a two criteria

G

Guest

I need to edit this code to delete rows if cells in column B are empty AND if
the corresponding cell in Column A is MC, Disc or Visa, is that possible?

Sub delRows()
Range("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
 
B

Bob Phillips

Sub ClearData()
Dim iRows As Long
Dim i As Long
Dim rng As Range

iRows = Cells(Rows.Count, "A").End(xlUp).Row
Columns(1).Insert
Rows(1).Insert
Range("A1").Value = "Temp"
Range("A3").Resize(iRows - 1).Formula =
"=AND(C2="""",OR(B2={""MC"",""Disc"",""Visa""}))"
Range("A1").Resize(iRows + 1).AutoFilter field:=1, Criteria1:=True
Set rng = Range("A1").Resize(iRows + 1).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
Columns(1).Delete
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top