+ Reply to Thread
Results 1 to 13 of 13

UDF MLOOKUP takes too much time. Alternative approach needed.

  1. #1
    Registered User
    Join Date
    07-18-2013
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    23

    UDF MLOOKUP takes too much time. Alternative approach needed.

    Hi

    I'm using UDF MLOOKUP form
    http://www.excelfox.com/forum/f12/vl...iple-values-4/
    Basically this is the the same function as lookup, but it returns multiple results in one cell.

    I have 2 sheets, where MLOOKUP is used multiple times to construct the reports. But it takes too much time and I had to turn off AutoCalculation on these sheets as the whole Workbook becomes very laggy. An when I turn it on again, it could take more than minute to calculate the results. As my database will become tens of times larger, I am thinking of ways to optimise it.

    Could you please advice me other approaches.

    Many thanks.


    P.S. Here is the code of this UDF.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Why not put all data on 1 sheet (instead of 2 sheets).

    Than a pivot table can probably help you to do your job.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    07-18-2013
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Quote Originally Posted by oeldere View Post
    Why not put all data on 1 sheet (instead of 2 sheets).

    Than a pivot table can probably help you to do your job.
    Separately these sheets take 82 and 45 respectively. If data is in one Sheet the results is 124 seconds. Thus there is only 3 second improvement. But thanks for the advice.

    I can't use pivot table, as my data is text and dates for the most part.

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    then show us the file, without confidential information, and the desired result.

  5. #5
    Registered User
    Join Date
    07-18-2013
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Here is the file. The target sheet is "Known Companies".
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    I think you posted confidential information in your sheet.

    Second, where do you have your Mlookup function (in which cell).

    Please add also the desired result in your sheet (please no zip file).

  7. #7
    Registered User
    Join Date
    07-18-2013
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Quote Originally Posted by oeldere View Post
    I think you posted confidential information in your sheet.

    Second, where do you have your Mlookup function (in which cell).

    Please add also the desired result in your sheet (please no zip file).
    1) No there is nothing confidential there
    2) MLOOKUPs are in columns C, E, F
    3) The desired result would be the same but taking less time to compute
    Ans sorry for *zip file, the website did not allow to upload more than 1 mb, so I had to compress it.


    Any suggestions are welcomed. Thanks in advance.

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    OK, with this information, I agree pivot table would not be the most practical solution.

    You got all the data on differant sheets.

    Sorry for that.

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    After a quick look at your workbook I would suggest it isn't the macro that's dragging the workbook down, it's the formulae you are using.

    You have an excessive amount of volatile functions, mainly INDIRECT().

    Your workbook is over complicated many sheets and tables are duplications of data already in the workbook, this combined with the volatile functions used to create them is a recipe for failure.

    This might seem hard on you, but your workbook needs serious reorganisation.
    There is no point in trying to find a solution to a situation that should not exist in the first place.

  10. #10
    Registered User
    Join Date
    07-18-2013
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Quote Originally Posted by Marcol View Post
    After a quick look at your workbook I would suggest it isn't the macro that's dragging the workbook down, it's the formulae you are using.

    You have an excessive amount of volatile functions, mainly INDIRECT().

    Your workbook is over complicated many sheets and tables are duplications of data already in the workbook, this combined with the volatile functions used to create them is a recipe for failure.

    This might seem hard on you, but your workbook needs serious reorganisation.
    There is no point in trying to find a solution to a situation that should not exist in the first place.
    Hi Marcol,

    Many thanks for the response.

    Well everything works pretty fine and smoothly besides these MLOOKUP functions and I use Indirect almost everywhere. The original list is much bigger and if AutoCalculation for sheets with MLOOKUPs is turned off I do not encounter any problems. Indirect functions are required as data imported can vary and columns can have different order, whereas headings stay the same. So it's either whole bunch of Indirect functions or scripting the search by headers in VBA.

    Other thing I can think of is to put data for indirect link directly into the report sheet as text (without formulas), so it won't go the whole way to calculate the route every time.

    What do you think?

  11. #11
    Registered User
    Join Date
    07-18-2013
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Quote Originally Posted by Marcol View Post
    After a quick look at your workbook I would suggest it isn't the macro that's dragging the workbook down, it's the formulae you are using.

    You have an excessive amount of volatile functions, mainly INDIRECT().

    Your workbook is over complicated many sheets and tables are duplications of data already in the workbook, this combined with the volatile functions used to create them is a recipe for failure.

    This might seem hard on you, but your workbook needs serious reorganisation.
    There is no point in trying to find a solution to a situation that should not exist in the first place.
    I just made an experiment. Replaced all the Indirect functions from MLOOKUPs and from all the sheets (just pasted values) and it has led to NO improvement in time at all. Not even a second faster. So it is clearly not the case.

  12. #12
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Your workbook is extremely difficult to follow, for me at least

    Where are you calling the UDF?

    In addition to volatile functions, you have 252 named ranges, references to whole columns, (this in 2007 and above is causing 1,048,576 calculations), etc.

    The function MLOOKUP() also calls whole columns

    Try this first and see if it returns the result you are expecting
    Please Login or Register  to view this content.
    This line in particular is returning 1,048,576 for the Ubound value
    For r = fFoundNo To UBound(KA1, 1)

    I'm pretty sure that most of the code is redundant, but first we need to clearly establish what you are trying to do.
    Last edited by Marcol; 08-16-2013 at 02:01 PM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  13. #13
    Registered User
    Join Date
    07-18-2013
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: UDF MLOOKUP takes too much time. Alternative approach needed.

    Quote Originally Posted by Marcol View Post
    Your workbook is extremely difficult to follow, for me at least

    Where are you calling the UDF?

    In addition to volatile functions, you have 252 named ranges, references to whole columns, (this in 2007 and above is causing 1,048,576 calculations), etc.

    The function MLOOKUP() also calls whole columns

    Try this first and see if it returns the result you are expecting
    This line in particular is returning 1,048,576 for the Ubound value
    For r = fFoundNo To UBound(KA1, 1)

    I'm pretty sure that most of the code is redundant, but first we need to clearly establish what you are trying to do.
    Many thanks for the response Marcol!

    My UDFs are in the sheet "Known Companies" in columns C, E and F.

    Sorry for making it too complex. Basically the idea is that each company has its unique number and information corresponding to this number which is imported from external and always updated.

    Because one company can have more than one note/tag/occasion, lookup and index/match approaches do not work, thats why I turned to mlookup.


    Your code alone allowed for 10 seconds improvement from 84 seconds to 74 seconds

    During the time I wrote this response I decided to test using limited number of cells in the row instead of the whole row. It calculated everything in 5 seconds. I think you resolved it - reference to the whole row (A:A; E:E etc) was making the whole think laggy. Thank you so much!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help for v-lookup approach instead of manually cell linking approach - Excel 2010
    By Mirisage in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-31-2013, 01:32 PM
  2. Using excel "find" takes a long time is there a better approach
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2011, 07:57 AM
  3. Replies: 6
    Last Post: 04-21-2010, 02:53 AM
  4. Trend? Growth? Mathematic approach needed.
    By Jimbras in forum Excel General
    Replies: 4
    Last Post: 05-25-2009, 11:54 AM
  5. Alternative to "On Error GoTo 0" that takes macro to last command?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2006, 01:10 PM

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