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 |
All times are GMT +1. The time now is 06:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com