Search and Delete Rows if 1 or more specific values in column cells

MrSpud

New Member
Joined
Jun 21, 2008
Messages
14
I would like row to be deleted if certain values are found in same row cell of column D

eg ROW 1 cell D 1 ,had 1 or more values of , ? " yes","no" then delete row
ROW 2 cell D 2 ,did not contain values of , " yes","no" then DONT delete row
 
Last edited:

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
This might work

VBA Code:
Sub t()
Dim i As Long
    With ActiveSheet
        For i = .Cells(Rows.Count, 4).End(xlUp).Row To 2 Step -1
            If InStr(1, .Cells(i, 4).Value, "yes", vbTextCompare) > 0 Or InStr(1, .Cells(i, 4).Value, "no", vbTextCompare) > 0 Then
                Rows(i).Delete
            End If
        Next
    End With
End Sub

The objective is a little confusing. I assume the question makr (?) was a typo.
 

MrSpud

New Member
Joined
Jun 21, 2008
Messages
14
This might work

VBA Code:
Sub t()
Dim i As Long
    With ActiveSheet
        For i = .Cells(Rows.Count, 4).End(xlUp).Row To 2 Step -1
            If InStr(1, .Cells(i, 4).Value, "yes", vbTextCompare) > 0 Or InStr(1, .Cells(i, 4).Value, "no", vbTextCompare) > 0 Then
                Rows(i).Delete
            End If
        Next
    End With
End Sub

The objective is a little confusing. I assume the question makr (?) was a typo.
Where does that code get placed?
soz
I prob need to hire someone
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Where does that code get placed?
soz
I prob need to hire someone
The code should be copied and pasted into code module1. See my signarure line below.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,768
Messages
5,626,765
Members
416,202
Latest member
donya ba

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
Top