is there a way delete rows based on cell values

vvkelley

New Member
Joined
Mar 27, 2011
Messages
7
Hi Folks,
I had a problem with a dataset I was working with and was wondering if anyone knew what I should do. I'm looking at the value's in a particular column and want to delete the entire row for anything with a specific combination of letters. Does anyone know how to do this systematically? I could hide them by filtering I know, but is there a way to delete them out right? I'm using excel 2007 on a windows 7 os. Many thanks for any help.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Here are a couple of options which employ the autofilter method.

I don't know how many requirements you have to delete so the first handles one and the second multiple.

Just abjust the sheet name and the column range.

Code:
Sub DelRows2()
    Application.ScreenUpdating = False
    With Sheets("Cases").Range("C1", Range("C" & Rows.Count).End(xlUp))
        .AutoFilter field:=1, Criteria1:="Yes"
        .Offset(1).EntireRow.Delete
        .AutoFilter
    End With
    Application.ScreenUpdating = True
End Sub

Code:
Sub DelRows1()
    Application.ScreenUpdating = False
    With Sheets("Sheet1").Range("B1", Range("B" & Rows.Count).End(xlUp))
        .AutoFilter field:=1, Criteria1:=Array("AAAA", "BBBB", "EEEE"), Operator:=xlFilterValues
        .Offset(1).EntireRow.Delete
        .AutoFilter
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Could you do a filter where only the rows you want to delete are visible and all the others are hidden? Then you can select the visible rows and delete them. Then turn off the filter.
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,303
Members
452,904
Latest member
CodeMasterX

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