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

MrSpud

New Member
Joined
Jun 21, 2008
Messages
23
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:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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