ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows with a two criteria (https://www.excelbanter.com/excel-programming/363397-deleting-rows-two-criteria.html)

JOUIOUI

Deleting rows with a two criteria
 
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



Bob Phillips

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






All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com