+ Reply to Thread
Results 1 to 3 of 3

vlookup to .xlsm macro is incredibly slow

  1. #1
    Registered User
    Join Date
    11-11-2008
    Location
    Syracuse NY
    MS-Off Ver
    2007
    Posts
    90

    vlookup to .xlsm macro is incredibly slow

    This is designed to be run on bid proposals, to calculate special discounts. My idea was that whoever was designing the bid would open this file, which has the discount information and the macro, and then run the macro on the file containing the bid.

    This macro works. It worked really fast when it was in my personal.xls and referenced an .xlsx file for the vlookup. It was slower, but still tolerable, when I moved it to the .xlsm file and it still refenced the .xlsx file (an oversight on my part). Now that I fixed the vlookup reference to the .xlsm file, the same one that the macro itself is in, it has slowed to a crawl. What is going on?

    Here's the relevant code. The four lines at the end, the ones that begin with ActiveCell are the ones that are taking all the time.

    Please Login or Register  to view this content.
    Last edited by jrussell; 07-23-2009 at 03:44 PM.

  2. #2
    Registered User
    Join Date
    11-11-2008
    Location
    Syracuse NY
    MS-Off Ver
    2007
    Posts
    90

    Re: vlookup to .xlsm macro is incredibly slow

    On rerunning this a couple of times, I've noticed that it was only slow on the four blue lines above when when I moved it to the .xlsm file and it still refenced the .xlsx file.

    When I fixed the vlookup references to use the .xlsm, every line of the macro was slow.

    But when I set Application.Calculation = xlCalculationManual at the beginning and Application.Calculation = xlCalculationAutomatic at the end, it speeds right up again.

    The problem is, I really hate using xlCalculationManual, because if the macro crashes it leaves Excel in manual calculation mode. Since I'm making this macro for use by people who are not all that skilled in excel, they will be totally stumped if this happens.

    So, is there another way to postpone calculation to the end of the macro?

    Or is there a way to speed up calculation the way it is? I don't see why the calculation is so much slower when the macro is saved as part of the .xlsm as opposed to saved in my personal.xls.

  3. #3
    Registered User
    Join Date
    11-11-2008
    Location
    Syracuse NY
    MS-Off Ver
    2007
    Posts
    90

    Re: vlookup to .xlsm macro is incredibly slow

    I figured this out. Turns out it was due to some external references in the workbook I was running the macro on. These were trying to recalculate any time I made any change in any open workbook. I got rid of those and now the macro's back to lightning fast. Funny, sometimes it's something completely different than you expect.

+ 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