Thread: search question
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default search question

I believe there is a typo in the posted version:

Private Sub CommandButton1_Click()
Dim sStr As String, rng As Range, cell As Range
Dim sAddr As String
sStr = Me.Range("D11").Value
With Worksheets("Data Stored")
Set rng = .UsedRange.Columns(1).Resize(, 2).Cells
End With
Set cell = rng.Find(What:=sStr, _
After:=rng(1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not cell Is Nothing Then
sAddr = cell.Address '<== correct this line
Do
Me.ListBox1.AddItem cell.Value
Set cell = rng.FindNext(cell)
Loop While cell.Address < sAddr
End If

End Sub

--
Regards,
Tom Ogilvy


"coolice" wrote in
message ...

Hi !

You are amasing !!!!

A VERY VERY VERY BIG THANK YOU !!!!!


The code is working perfectly, except one small issue, that it never
stops. It is looping forever.

Is there any idea why it can be ?

It is doinf exactly what need, just never stops, and the Excel keep
frozen because of this.

Many thank you in advance,

Moore


--
coolice
------------------------------------------------------------------------
coolice's Profile:

http://www.excelforum.com/member.php...o&userid=27526
View this thread: http://www.excelforum.com/showthread...hreadid=470475