Delete Rows

K

kkondrat1

Hello, I have two columns with data that I need to use to filte
out/delete rows.

columns C and K

I want to delete all rows that contain "H72" in column C AND contai
"H73" in column K.

This is what I am using, which works great for one column:

Sub Delete_Rows()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("C:C"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "H72" _ Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Su
 
D

Don Guillett

try
If (cell.Value) = "H72" _ Then
If cell = "H72" or cell.offset(,8)="H73" Then
 
J

jeff

Hi,

Try this code:

Sub Delete_Rows()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("C:C"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "H72" And cell.Offset(0, 8).Value
= "H73" Then
Set del = cell
del.EntireRow.Delete
End If
Next cell
On Error Resume Next
End Sub

jeff
 
Top