View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Once criteria has been met, delet the same row.

Sub deleterows()
Dim lLastRow As Long
Dim x As Long
Dim arr as Variant
Dim i as long
arr = Array("AEPA", "ASPA", "AEPE", "AEPR", _
"ALPA", "AZPA", "AZPE" ,"LA" ,"LG" , "LU", "NB")
lLastRow = Range("A65536").End(xlUp).Row
For x = lLastRow To 1 Step -1
If UCase(Left(Range("A" & x).Offset(0, 2).Value, 1)) = "H" Then
Range("A" & x).EntireRow.Delete
Else
for i = lbound(arr) to ubound(arr)
if Instr(1,Range("A" & x).Offset(0,2).Value,arr(i),vbTextCompare) Then
Range("A" & x).EntireRow.Delete
Exit for
end if
Next
End If
Next x

End Sub

"Les Stout" wrote in message
...
Hi Nick/Don,

Thanks very much for the help, I really appreciate it.

Nick,

I also have the following and have tried to change the code to suit but
I cannot get it to work, Heeeelp ??

Like previously mentioned, I have1 10 starting with "H" and the rest
are, they must all be deleted;

AEPA, ASPA, AEPE, AEPR, ALPA, AZPA, AZPE ,LA ,LG , LU & NB.

I don't think i understand the language, as I tried changing the code by
changing "H" to "*PA", but it still did not work, has it something to do
with the for x ?

Can you use the wild card with as well?

As stated, I new to the game, but love it and very frustrated at this
stage, as I know what I want to do, but can't !!


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!