Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Range.Find gets slow

After I use Range.Find method programmatically, the standard search on sheets
dramatically slows down. What could be the reason and how can this side
effect be taken out? Thanks!
After I use Range.Find method programmatically, star=ndard it searches

The relevant code is


Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
...
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And (Rng.Address < firstAddress)
End If

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Range.Find gets slow

What's in this bit

If Not Rng Is Nothing Then

Else


Regards,
Peter T

"vbapro" wrote in message
...
After I use Range.Find method programmatically, the standard search on

sheets
dramatically slows down. What could be the reason and how can this side
effect be taken out? Thanks!
After I use Range.Find method programmatically, star=ndard it searches

The relevant code is


Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
...
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And (Rng.Address < firstAddress)
End If



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Range.Find gets slow

Try this code

Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
For each cell in Rng
'enter your code here
next cell
End If


"Peter T" wrote:

What's in this bit

If Not Rng Is Nothing Then

Else


Regards,
Peter T

"vbapro" wrote in message
...
After I use Range.Find method programmatically, the standard search on

sheets
dramatically slows down. What could be the reason and how can this side
effect be taken out? Thanks!
After I use Range.Find method programmatically, star=ndard it searches

The relevant code is


Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
...
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And (Rng.Address < firstAddress)
End If




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Range.Find gets slow

Thank you for the interest!

The code fragment is used in a UserForm. It fills a listbox

Set Rng = .Find("*" & What & "*", LookIn:=xlValues)
If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
Me.ListBox1.AddItem Rng.Row
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address < firstAddress
End If




"Peter T" wrote:

What's in this bit

If Not Rng Is Nothing Then

Else


Regards,
Peter T

"vbapro" wrote in message
...
After I use Range.Find method programmatically, the standard search on

sheets
dramatically slows down. What could be the reason and how can this side
effect be taken out? Thanks!
After I use Range.Find method programmatically, star=ndard it searches

The relevant code is


Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
...
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And (Rng.Address < firstAddress)
End If




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Range.Find gets slow

Nothing obvious in what you have shown that would make it slow, I half
expected something else in your loop that would have done.

I just gave your code a pretty severe test in my very old setup, Find
*a-word* in a long string in 200 cells scattered in 500k cells. It populated
the list with 200 row numbers very quickly.

What is .Find and .FindNext qualified with, how many 'found' cells (include
a counter in the loop), any difference if you comment the code that
populates the list.

Regards,
Peter T

"vbapro" wrote in message
...
Thank you for the interest!

The code fragment is used in a UserForm. It fills a listbox

Set Rng = .Find("*" & What & "*", LookIn:=xlValues)
If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
Me.ListBox1.AddItem Rng.Row
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address < firstAddress
End If




"Peter T" wrote:

What's in this bit

If Not Rng Is Nothing Then

Else


Regards,
Peter T

"vbapro" wrote in message
...
After I use Range.Find method programmatically, the standard search on

sheets
dramatically slows down. What could be the reason and how can this

side
effect be taken out? Thanks!
After I use Range.Find method programmatically, star=ndard it

searches

The relevant code is


Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
...
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And (Rng.Address < firstAddress)
End If








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Range.Find gets slow

Thank you, Peter!

I must have unclearly explained. The problem is in the following. There are
about 20000 cells searched. First time when I use the standard Find dialog
box (Ctrl+F in Excel Worksheet view), the results are found in about a
second. After I have run the Find method of a Range object programmatically,
the standard search looks slowly over the cells, what is seen in the Name Box.

"Peter T" wrote:

Nothing obvious in what you have shown that would make it slow, I half
expected something else in your loop that would have done.

I just gave your code a pretty severe test in my very old setup, Find
*a-word* in a long string in 200 cells scattered in 500k cells. It populated
the list with 200 row numbers very quickly.

What is .Find and .FindNext qualified with, how many 'found' cells (include
a counter in the loop), any difference if you comment the code that
populates the list.

Regards,
Peter T

"vbapro" wrote in message
...
Thank you for the interest!

The code fragment is used in a UserForm. It fills a listbox

Set Rng = .Find("*" & What & "*", LookIn:=xlValues)
If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
Me.ListBox1.AddItem Rng.Row
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address < firstAddress
End If




"Peter T" wrote:

What's in this bit

If Not Rng Is Nothing Then

Else

Regards,
Peter T

"vbapro" wrote in message
...
After I use Range.Find method programmatically, the standard search on
sheets
dramatically slows down. What could be the reason and how can this

side
effect be taken out? Thanks!
After I use Range.Find method programmatically, star=ndard it

searches

The relevant code is


Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
...
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And (Rng.Address < firstAddress)
End If







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Range.Find gets slow

OK I tried to recreate what you describe but all seems to work at roughly
same speed in multiple calls to find. Can you describe a simplified
scenario that's easy for others to recreate that will demonstrate the
problem.

Regards,
Peter T


"vbapro" wrote in message
...
Thank you, Peter!

I must have unclearly explained. The problem is in the following. There

are
about 20000 cells searched. First time when I use the standard Find dialog
box (Ctrl+F in Excel Worksheet view), the results are found in about a
second. After I have run the Find method of a Range object

programmatically,
the standard search looks slowly over the cells, what is seen in the Name

Box.

"Peter T" wrote:

Nothing obvious in what you have shown that would make it slow, I half
expected something else in your loop that would have done.

I just gave your code a pretty severe test in my very old setup, Find
*a-word* in a long string in 200 cells scattered in 500k cells. It

populated
the list with 200 row numbers very quickly.

What is .Find and .FindNext qualified with, how many 'found' cells

(include
a counter in the loop), any difference if you comment the code that
populates the list.

Regards,
Peter T

"vbapro" wrote in message
...
Thank you for the interest!

The code fragment is used in a UserForm. It fills a listbox

Set Rng = .Find("*" & What & "*", LookIn:=xlValues)
If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
Me.ListBox1.AddItem Rng.Row
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address < firstAddress
End If




"Peter T" wrote:

What's in this bit

If Not Rng Is Nothing Then

Else

Regards,
Peter T

"vbapro" wrote in message
...
After I use Range.Find method programmatically, the standard

search on
sheets
dramatically slows down. What could be the reason and how can this

side
effect be taken out? Thanks!
After I use Range.Find method programmatically, star=ndard it

searches

The relevant code is


Set Rng = .Find("*" & What & "*", LookIn:=xlValues)

If Not Rng Is Nothing Then
firstAddress = Rng.Address
Do
If Not Rng Is Nothing Then
...
Else
Exit Do
End If

Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And (Rng.Address <

firstAddress)
End If









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find & Replace Very Slow in VB But Not Manually Chrisso Excel Programming 3 February 5th 07 02:27 PM
ADO - recordset find performance slow Ken Valenti Excel Programming 5 September 23rd 06 07:23 PM
slow processing with .find Guy Normandeau Excel Programming 6 June 14th 06 06:40 PM
Slow 'FIND' when entering a value in Combobox bdn435 Excel Programming 0 April 25th 06 12:55 PM
Find function very slow, when XLS window is not active Yakimo[_3_] Excel Programming 0 May 30th 04 10:17 AM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"