Auto Deleting Rows Based on Cell Data

K

kukarooza

Hi and thanks up front for any help you might can give me. I've go
several rows of data that I need to filter out and I'd rather not hav
to review each line individually to do this. Here's what I'd like t
be able to do...

Example:
I have columns A-M and in column D, there is either a Y or an N. I'
like to do something that would automatically delete every row that ha
an N in column D.

Is this possible
 
I

icestationzbra

this piece of code should help, just replace 'Sheet1' with the name o
the sheet (Account, if that is the name of your sheet) that has th
data:

Option Explicit

Sub DeleteRows()

Dim i As Integer
Dim n As Integer

With Sheet1

n = .Range("d1").CurrentRegion.Rows.Count

For i = 2 To n

If (UCase(.Range("d" & i).Value) = UCase("N")) Then

Range("d" & i).EntireRow.Delete

Else

GoTo None

End If

Next i

End With

None:
MsgBox "No rows to delete!"

End Su
 
M

Myrna Larson

The quickest way is to just sort on column D, which will put the N rows
together at the top. Then delete them.

If you need to retain the original order, then as a first step, in column N,
use Edit/Fill/Series to fill it with ascending numbers 1-n. Then sort on
column D, delete the rows at the top, then sort on column N to get the
original order back.
 
Top