+ Reply to Thread
Results 1 to 13 of 13

Optimization of the Find() Function

  1. #1
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Lightbulb Optimization of the Find() Function

    Hi guys,

    I use a lot the function “Find” in Excel but the problem is that it takes a lot of time, so I’m searching for another function or code that can be faster than that, the Worksheets that I use in Excel contain thousands of sheets so it takes hours to execute the Macro.

    Please Helpppppp

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Optimization of the Find() Function Helppp

    Find is pretty fast itself.

    need to look at your code to find an optimization.

    Have you tried things like:
    HTML Code: 
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Optimization of the Find() Function Helppp

    I use all this functions in all my macros. I have a lot of diffrent code where i use "Find", so i need a universal function that can replace Find to reduce the time of execution, this is what i'm searching for, i tried to replace it with many loop but it was even slower.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Optimization of the Find() Function Helppp

    There is no generic alternative. There might be things that are faster in particular situations, but generally speaking, as mentioned, Find is pretty fast. If you truly have thousands of sheets in your workbooks, then your problem is your workbook structure - anything that has to search through all of them is going to take time.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Optimization of the Find() Function Helppp

    I usualy use the function like this:

    Cells.Find(what:="case 2", after:=Range("A2")).Select

    I tried to replace it with several codes but it was even slower then find like for exemple a search in each colomne using a loop.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Optimization of the Find() Function Helppp

    Select is almost never necessary and is slow and inefficient, so you should avoid it. Besides that you shouldn't use a Find and Select in the same operation since it will error if the data is not found.

  7. #7
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Optimization of the Find() Function Helppp

    And you search in all cells. Can you use
    Please Login or Register  to view this content.
    and seing this I wonder how you loop through all the sheets
    I guess it will be something like
    Please Login or Register  to view this content.
    as I do not see a Ws1.cells.Find ...
    Last edited by rwgrietveld; 02-16-2010 at 09:53 AM.

  8. #8
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Optimization of the Find() Function Helppp

    Well in fact i tried to search column by column, so if the number that i'm searching for is at the begining it's even faster that Find but if it's far il will take a lot of time

    What do you think, is there another way???
    Last edited by pierre08; 02-18-2010 at 04:20 AM.

  9. #9
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Optimization of the Find() Function

    Hey guys,

    Is it possible to use an autoFilter in the WorkSheets, can it be faster to Find a Value?
    What do you think?
    Last edited by pierre08; 02-19-2010 at 05:58 AM.

  10. #10
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Optimization of the Find() Function

    Is it possible to use an autoFilter in the WorkSheets, can it be faster to Find a Value?
    What do you think guys.??
    Does anyone have an exemple for that?

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Optimization of the Find() Function

    It depends. If you are looking for one occurrence, find will be faster. (again, Find is not inherently slow)

  12. #12
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Optimization of the Find() Function

    Hi guys,
    if i used an array: worksheet= array, can the search be faster? and does anyone knows the code to do that?
    Thank you

  13. #13
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Optimization of the Find() Function

    Doubtful - you would have to loop through every item in the array. It sounds to me like you need a database, or at least a better workbook structure. I can't think of any good reason why you would need to search every column for a piece of data - if you know what kind of data you are looking for, you should only be searching the columns that contain it. You would also still be better off not having so many sheets - it will make everything a lot easier.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1