+ Reply to Thread
Results 1 to 5 of 5

Compile VBA for faster execution

  1. #1
    Registered User
    Join Date
    12-05-2006
    Location
    Philadelphia PA
    MS-Off Ver
    Office 365
    Posts
    81

    Compile VBA for faster execution

    VBA offers marvelous functionality, but being an interpreted language, it is very slow compared to worksheet functions. I would like to compile all or most of the subroutines in my application so they run much faster, hopefully at least 10 times faster. I believe that you have to first convert the VBA code to another language, such as VB or C++, and then use a compiler for that language to create a dll or xll, which can then be referenced in the Excel file.

    I have been searching the Internet for products that would do this work for me. So far I haven't found much; perhaps I'm not searching the right way. Can anyone suggest specific software for this purpose?

    Some of the products I've seen will also compile the worksheets as well as the VBA code, with the intent of hiding proprietary formulas and/or transforming the entire application into a .exe. That's nice, but I don't need that, at east not yet. I just want to make the VBA code run much faster without losing any functionality.

    Would appreciate any recommendations and words of wisdom.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: How best to compile VBA for much faster execution

    Good evening batman

    What your actually referring to is known as a COM Add-In. A COM Add-in will run considerably faster than VBA and will offer increased security in terms of people breaking into / reverse engineering your work in any way.

    You can only do this with add-ins. You can't just convert any existing modules in a workbook. You are right that your code will need converting, but there is no application that will do this for you. It will need rewriting again from the start. And you will need to learn the language which you want to use before you do it. Using Visual Basic (as it is now called, as opposed to VB6 or VB.Net) would probably be easier (if you don't already know C++) as the syntax is identical, but there are many extra objects / instructions to come to terms with.

    I would suggest you have a look here which is where you can download free 2008 Express versions of the Visual Studio Tools (Visual Basic, Visual C#, Visual C++).

    You might also like to have a look at Chip Pearson's introduction to the subject here.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: How best to compile VBA for much faster execution

    hi,

    Edit: Ooopps I was too slow!
    At least DominicB's answer is more knowledgeable :-)

    VBA's the only language I know (so far) so I can't help with your specific question but I (or others) may be able to help you achieve your aim of faster execution through review of your code - are you able to upload any for us to review?

    For tips on good VBA coding have a read of http://www.excelforum.com/excel-prog...id-in-vba.html

    If you're already using all the best practices & still want more speed then hopefully someone else can answer your question...

    I'm curious though so I went looking & a quick Google search shows:
    http://support.microsoft.com/kb/306130
    http://www.xtremevbtalk.com/archive/.../t-264506.html (discusses MS Access but I think the links listed would apply for Excel too as it is all using VBA)
    http://www.xtremevbtalk.com/showthre...967#post619967 (some knowledgeable discussion)

    hth
    Rob
    Last edited by broro183; 03-13-2010 at 06:59 PM.
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Registered User
    Join Date
    12-05-2006
    Location
    Philadelphia PA
    MS-Off Ver
    Office 365
    Posts
    81

    Re: How best to compile VBA for much faster execution

    Thanks dominicb

    I looked at CPearson's material as you suggested. There's a lot there to digest. I have VB experience, although not recent (I think I got up to VB4). I also have an Express version of Visual Studio, although I have done nothing with it yet. I may have to start getting my feet wet, very wet.

  5. #5
    Registered User
    Join Date
    12-05-2006
    Location
    Philadelphia PA
    MS-Off Ver
    Office 365
    Posts
    81

    Re: How best to compile VBA for much faster execution

    Thanks broro183, the hour is late now, but I will look at the links you provided starting tomorrow.

+ 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