+ Reply to Thread
Results 1 to 4 of 4

Speeding up a custom lookup function

  1. #1
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Speeding up a custom lookup function

    I've been writing a custom function to sum numbers from a matrix based on multiple criteria. One criterion is matched against the values in the first row of the matrix, one against the values in the left most column of the matrix and one matched against any cell in the matrix.
    When all criteria - if not optional - are matched the value offset to the last found cell are added to a total.
    Finally the resulting total is returned by the function.

    Problem with this function is that it is terribly slow.
    Can anyone give me suggestions/directions on how to speed it up?

    Please Login or Register  to view this content.
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Speeding up a custom lookup function

    Hi, Tsjallie,

    depending on how often the values will appear in the matrix you could either use WorksheetFunction.Match for one item or Find/FindNext for more items.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Speeding up a custom lookup function

    Hi Holger,
    thanks for your suggestion.
    As I need one item at time I think the match-function can be a serious option for the horizontal and vertical lookups.
    It worries me that I didn't come to think of that myself
    I'll have a play with it and let you know the results.

  4. #4
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Speeding up a custom lookup function

    Hi Holger,
    I think it's gonna be the find function after all.
    Plan is to create arrays with matching columns and matching rows and then using the index function to evaluate the individual cells (floating criteria).
    I'm sure this will speed up things, though I haven't found the time yet to finish the function.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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