Delete Rows

  • Thread starter Thread starter kkondrat1
  • Start date Start date
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
 
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
 
Of course I meant AND

--
Don Guillett
SalesAid Software
(e-mail address removed)
Don Guillett said:
try
If (cell.Value) = "H72" _ Then
If cell = "H72" or cell.offset(,8)="H73" Then
 

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

Similar Threads

Excel VBA 1
Delete Rows help? 4
Refer to cell in diff sheet 1
Delete Row Help 2
Macro deletes seperately 4
Deleting Certain columns 3
Unable to Loop Multiple Worksheets 4
Range selection 6

Back
Top