View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default delete all rows not beginning with

Here is one approach:

Sub RowKiller()
Dim r As Range, rKill As Range
Set r = Intersect(ActiveSheet.UsedRange, Range("A:A"))
Set rKill = Nothing
For Each rr In r
v = rr.Value
If v = "AAAF800" Or v = "AAAF900" Or v = "AAAF1000" Then
Else
If rKill Is Nothing Then
Set rKill = rr
Else
Set rKill = Union(rKill, rr)
End If
End If
Next
If rKill Is Nothing Then
Else
rKill.EntireRow.Delete
End If
End Sub

We build a set of rows and delete them in one swell foop!
--
Gary''s Student - gsnu200908


"SITCFanTN" wrote:

I need to write some code that would delete all rows in the open document
where AAAF800 or AAAF900 or AAA1000 are not in column A. I have searched the
site and am not able to find anything that would help me with this. Any
suggestions are greatly appreciated. Thank you,