View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default Selecting rows based on a value

This should do the trick
Sub Remove_Unwanted_Rows()
'his deletes all rows with cells not matching cases
Const whatColumn As String = "A"
Dim rng As Range
Dim Cell, RowArray As Range
Set rng = ActiveSheet.Range(Cells(1, whatColumn), _
Cells(Rows.Count, whatColumn).End(xlUp))
For Each Cell In rng
Select Case Cell
Case Is < "A" '& any others you like separted by commas
If RowArray Is Nothing Then
Set RowArray = Cell.EntireRow
Else
Set RowArray = Union(RowArray, Cell.EntireRow)
End If
End Select
Next Cell
On Error Resume Next
Debug.Print RowArray.Address
RowArray.delete
Err.Clear
End Sub

"Jeff Parrott" wrote:

I have a large spreadsheet that I need to sort on a daily basis. I have
several macros that I use to sot and delete rows but I can't figure out how
to do one thing.

The rows all contain data based on warehouse locations. The first column of
the sheet lists all of the warehouses based on letter designations (A,B,C...)
I want to select the rows containing data related to warehouse "A" and delete
everything else. Any suggestions?

--
Whether you think you can or cannot, you're right. - Henry Ford