+ Reply to Thread
Results 1 to 7 of 7

Code efficiency

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Code efficiency

    Hello all members,

    Many people who use macros first tend to use the internal Excel VBA recorder to record what they need excel to do (e.g. format cells, add formulas, etc). Recently I have realized the inefficiency associated with the resulting code requiring some cleaning up and removal of unneeded pieces of code. Since I am still new to world of vba, I would please ask everyone who has experience with this issue to list tricks they know to increase the efficiency of the recorded code. For example, in a recent thread, I asked for advice on how to deal with. Select http://www.excelforum.com/excel-prog...-in-macro.html and was given some very useful advice. I hope that members of this forum will be able to share their experience so that newcomers will find one source for making their macros more efficient.

    Thanks.

    abousetta
    Last edited by abousetta; 04-28-2010 at 01:26 AM. Reason: delete HTML tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code efficiency

    Hello abousetta,

    Wow, that is like asking, "Explain the universe and give three examples." That is a very broad question and not one that can be answered in a few sentences. Books have been written on this subject. If you had some specific code examples in mind, that would provide a better starting point for the discussion.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-23-2010
    Location
    Albuquerque, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Code efficiency

    If you are looking for just a few quick tips on cleaning up recorded macros what I would suggest is once it is recorded go in are remove all scrolls and all selects that are not absolutly needed other then that I would be writing an textbook.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code efficiency

    You could read through the thread at http://www.excelforum.com/excel-prog...id-in-vba.html

    Take some of what you read there with a grain of sand. My recommendations are, of course, grains of gold.
    Entia non sunt multiplicanda sine necessitate

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

    Re: Code efficiency

    As Leith says, you've asked a very broad question. In return, here's a very broad answer: http://www.excelforum.com/excel-prog...id-in-vba.html
    Note, it's a good idea to read the whole thread because some points (eg mine!) are over-ruled/corrected by more knowledgeable members in subsequent posts.

    Edit: I posted before seeing Shg's reply. But after seeing Shg's reply, I'll add...
    LOL, in other words, I've shared some of the grains of sand! /end edit

    btw, to create a link in your post, use the World icon that has a chain link on it (rather than the HTML icon).

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

  6. #6
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Code efficiency

    Thank you all for your posts and I agree that its a big topic but nonetheless an important one. I will go through the suggested links and start a new thread with any specific questions. In the meantime, are there any further links anyone would like to suggest for tips on streamlining vba code?

    abousetta

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

    Re: Code efficiency

    I suggest reading anything that you can get your hands on - the more you read the more you will learn, even with the caveat that you may have to brush off the occasional grain of sand. Here are some links:

    http://msdn.microsoft.com/en-us/library/aa730921.aspx
    Also, read through the author's site http://www.decisionmodels.com/

    http://www.thecodecage.com/forumz/ex...de-2007-a.html

    http://blogs.msdn.com/excel/archive/...-in-excel.aspx

    http://blogs.msdn.com/excel/archive/...practices.aspx

    For a specific example discussed at length by DonkeyOte & others: http://www.experts-exchange.com/Soft..._25891900.html

    hth
    Rob

+ 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