Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Find function very slow, when XLS window is not active

Hi there,

Using OLE automation (C#) I found out that the function .Find(...) is
EXTREMELY slow, when the XLS file doesn't have a focus.
After that I made some tests only with Excel and I found, that FIND is very
fast (milliseconds), when my XLS workbook is active. But if I run my Macro
containing Find() code, select (f.ex.) Explorer and let the Find works, it
takes several seconds to find my cell.
My code is straight forward:

'-------------------------------- begin code
Dim i As Long

' -- dummy loop, to be able to select some other window, not VBA or EXCEL
Range("C65000").value="4"
For i = 1 To 10000
Cells(i).Select
Next
Dim r As Range
Debug.Print "Finding..."
Set r = Range("$C:$C").Find(What:="4", After:=Range("C100"),
LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False)
Debug.Print "Found " & r.Address
'------------------------------------------------ end code

If I run my Macro from my XLS and DO NOT change the focus, Find takes
milliseconds.
If I run my code and select some other window from my Taskbar, Find takes
around 10 seconds!!!

Any ideas why this is like that?
What can I do speedup my Find? I call my Find in a loop several times and
this delay is killing for me.

Regards,
Yakimo


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
how to open a workbook per active window Jackie[_2_] Excel Discussion (Misc queries) 1 August 19th 08 11:13 PM
missing Active Window bar Gomer Fackworth New Users to Excel 4 May 28th 08 02:13 PM
How to Determine if Application Window Still Active Edwin Kelly Excel Discussion (Misc queries) 3 June 26th 07 05:42 PM
Active Window Question CWillis Excel Discussion (Misc queries) 4 July 19th 06 05:52 PM
Excel 2003 Slow Function Argument Window [email protected] Excel Discussion (Misc queries) 2 June 28th 05 06:53 PM


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

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

About Us

"It's about Microsoft Excel"