Help required for Inefficient nested loop

  • Thread starter Thread starter Kobayashi
  • Start date Start date
K

Kobayashi

I'm sure this is very simple and hopefully somebody can help with th
following:

The loops work but if the ISLIKE value does = false I would like th
'l' loop value, after deleting the row, to reset back to '1' and mov
onto the next 'm' value. At the moment the For l loop continues to ru
for each cell in the range, which is approx. twenty values, and
therefore, could be speeded up considerably if I only knew how?!


For m = myrange.Rows.Count To 4 Step -1
For l = 1 To LUrange.Rows.Count
If ISLIKE(myrange.Cells(m, 1), LUrange.Cells(l, 1) & "*")
False Then
myrange.Cells(m).EntireRow.Delete

End If
Next l
Next m


Thanks,

Adria
 
For m = myrange.Rows.Count To 4 Step -1
For l = 1 To LUrange.Rows.Count
If ISLIKE(myrange.Cells(m, 1), _
LUrange.Cells(l, 1) & "*") = False Then
myrange.Cells(m).EntireRow.Delete
Exit For
End If
Next l
Next m
 
Tom, as always, you are a superstar!

I appreciate that advising me of a missing 'Exit For' statement may no
have been very challenging for you but my 'm' loop will have upt
60,000 rows so you can imagine how much time this will save me both o
this occasion and going forward!!!

Your prompt response will also save me hours of head scratching thi
evening!

I was quite close again as I did try using exit and end but, obviousl
without success. 'Exit For' - quite embarrassing but a lesson I wil
not be forgetting in a hurry!

Many thanks once again!

Adrian :
 
Back
Top