DELETE ROW 3 MATCHING CRITERIA

  • Thread starter FIRSTROUNDKO via OfficeKB.com
  • Start date
F

FIRSTROUNDKO via OfficeKB.com

HI!

I am loooking fo a macro that will delete 2 rows based a delete being in the
2nd row and the data in col A ans B being the same.

i.e before

Car Bus net 1 USD
Car Bus delete NOFAIR
Car Train net 2 USD
Plane Walking net 5 USD
Plane Bus delete NOFAIR

after

Car Train net 2 USD
Plane Walking net 5 USD
Plane Bus delete NOFAIR

Thanks in Advance

Darren
 
T

Tom Ogilvy

Sub deleterows()
Dim lastrow as Long, i as Long
set lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 1 step -1
if cells(i,1).value = cells(i,2).value and cells(i,3).value = "delete"
then
rows(i).delete
end if
Next
End Sub
 
D

Don Guillett

try
Sub deleteifsame()
On Error Resume Next
For i = Cells(Rows.Count, "a").End(xlUp).Row To 1 Step -1
If UCase(Cells(i, "c")) = "DELETE" And _
Cells(i - 1, 1).Value = Cells(i, 1).Value And _
Cells(i - 1, 2).Value = Cells(i, 2).Value Then
Cells(i - 1, 1).Resize(2).EntireRow.Delete
End If
Next i
End Sub
 

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