Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to open a workbook per active window | Excel Discussion (Misc queries) | |||
missing Active Window bar | New Users to Excel | |||
How to Determine if Application Window Still Active | Excel Discussion (Misc queries) | |||
Active Window Question | Excel Discussion (Misc queries) | |||
Excel 2003 Slow Function Argument Window | Excel Discussion (Misc queries) |