View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Deleting rows that contain a certain value in column A

How about removing "misery" something like this non-looping way instead?

Sub StayHappy()
Dim Word As String
Word = "misery"
Columns("A").AutoFilter Criteria1:=Word, Field:=1, VisibleDropDown:=False
Range("A1:A" & ActiveSheet.UsedRange.Rows.Count).Offset( _
Abs(Range("A1").Value < Word)).EntireRow.Delete
ActiveSheet.AutoFilterMode = False
End Sub

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Suppose we want to remove "misery":

Sub StayHappy()
Dim n As Long
Dim i As Long
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "A").Value = "misery" Then
Rows(i).Delete
End If
Next
End Sub

--
Gary''s Student - gsnu200848


"Bishop" wrote:

I have a spreadsheet sorted by column A. I need a procedure that will
find
every cell with a specific value (they will all be grouped together
because
of the sort) in column A and delete every row (ever how many it is) that
has
that value in column A. Then I need the remaining data shifted up.