Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2007

Tip: Looking for answers? Try searching our database.

Can anyone explain to me why built in Cells.Find() is faster than a loop?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Will - 06 Nov 2007 18:25 GMT
When coding in VB, why are the built in applications, particularly
Cells.Find(), faster than loops?
Dave Peterson - 06 Nov 2007 19:34 GMT
If you had to check 64k or 1MB cells in a column for a certain string that
appears 3 times, .find would be lots faster.

If you that string appears in every cell, then I bet the loop would be just as
fast or faster (not tested, though).

> When coding in VB, why are the built in applications, particularly
> Cells.Find(), faster than loops?

Signature

Dave Peterson

ilia - 06 Nov 2007 20:18 GMT
Part of the reason is because they're fully compiled and generally
pretty well optimized.  VB code is interpreted at runtime, which is
usually slower.

> When coding in VB, why are the built in applications, particularly
> Cells.Find(), faster than loops?
Charles Williams - 07 Nov 2007 19:25 GMT
Hi Will,

There is a significant overhead in transferring data from Excel to VBA, but
when you are dealing with methods like .Find that operate directly on Excel
ranges then the data does not need to be transferred. so you avoid the
overhead.
Also Excel's methods such as FIND are written in C language rather than VBA,
which tends to be faster in execution.

(Even faster than Cells.Find is using WorksheetFunction.Match)

When coding in VBA there are generally many different ways of coding the
same task, and some are very much faster than others.

(Come to my session on writing fast User-defined Functions at the UK User
Group Conference to find out more!)

Charles
_________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

> When coding in VB, why are the built in applications, particularly
> Cells.Find(), faster than loops?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.