View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Filtering or deleting multiple rows

Start here
http://www.rondebruin.nl/delete.htm

For example try this one

This will check column A (Change it to the column you want)
'We check the values in the A column in this example
With .Cells(Lrow, "A")

Add the other values to the array in the macro

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

You can also add a list of values on another worksheet if you find that easy ?



Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet

'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

'We check the values in the A column in this example
With .Cells(Lrow, "A")

If Not IsError(.Value) Then

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

End If

End With

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message ...
I'm not exactly a new user, but this is the first time in a while that I've
had to apply this knowledge to my professional duties. The spreadsheet I'm
working on is considerably large and I need to retain rows that contain
certain text or specific criteria. For example, I only need items A, C, H,
and P, and Z out of a document that has everything else (i don't need) in
between. How do I delete based on specific criteria (letter, city name,)
withouth scrolling down and sifting through it manually? Please help me.