View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] BrianWest83@gmail.com is offline
external usenet poster
 
Posts: 4
Default Delete Rows based on cell value

On Jan 16, 5:26 pm, carlo wrote:
You could do following:

Sub DelRows()

Dim SH As Worksheet

Set SH = Worksheets("sheet1")

For i = SH.Cells(65536, 5).End(xlUp).Row To 6 Step -1
If LCase(SH.Cells(i, 5).Value) < "abc" Then
SH.Rows(i).Delete
End If
Next i

End Sub

hth
Carlo

On Jan 17, 10:19 am, wrote:

Hi. I'm trying to create a macro that will delete rows where the
value in column E does not equal "ABC". I always have a different
number of rows of data so I can't use a fixed range. Also, rows 1-5
are my header rows so I don't want to touch them--so the macro should
start looking at column E in row 6 and continue until it hits a row
where column E is blank. Thanks in advance.


For some reason that deleted ALL the rows including those with "ABC"
in column E. (It didn't delete the header rows though, which is good.)