delete rows if

Parra

Well-known Member
Joined
Feb 21, 2002
Messages
752
I have no idea how to write a macro that would do this but this is what I need.

If in column b the word "count" appears in a cell with other text and if next to it in column c equals "1". I want that row and the row above it to be deleted.

Cause I don't know how to write this, I am currently doing this manually.

Please help, I'm growing very impatient. Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Sub Deleter()
del = InputBox("Text to delete + 4 rows?", , ActiveCell.Value)
On Error Resume Next
1:
Set rw = Columns(1).Find(del, lookat:=xlWhole)
If Not rw Is Nothing Then
rw.Resize(5).Delete
GoTo 1
End If
End Sub
 
Upvote 0
Thanks for the help but I made a minor mistake and I don't know if it will effect the macro.

The word "count" is in column a and the number 1 is in column b.

Please let me know, thanks.
 
Upvote 0

Forum statistics

Threads
1,213,537
Messages
6,114,216
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top