View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Deleting rows with a two criteria

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)

"JOUIOUI" wrote in message
...
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).Entire Row.Delete
End Sub