+ Reply to Thread
Results 1 to 6 of 6

More Efficient: Calling smaller macros or one Big macro?

  1. #1
    Registered User
    Join Date
    05-23-2018
    Location
    Texas, United States
    MS-Off Ver
    2013
    Posts
    39

    More Efficient: Calling smaller macros or one Big macro?

    I'm newer to VBA and am trying to learn the best way to make efficient Macros. Is it better to combine similar functions (like changing something on different graphs) into one big macro, or to make them all smaller macros and then have a "Run_All" Macro that calls them all?
    Last edited by jakegordon97; 07-19-2018 at 05:40 PM.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: More Efficient: Calling smaller macros or one Big macro?

    This, I feel, is another of those things that come down to individual taste.

    I use lots of smaller subs when I have the need to run similar actions on similar objects. So if I want to perform the same changes to a group of different charts I would probably have a small bit of code to do that and pass variables to it from my main sub in order to tailor make the code to each relevant chart, rather than repeat the same bit of code several times each with a slight adjustment.

    There are times when one big sub is a good idea as it makes it a lot easier to read through and work out what's going on without jumping around from sub to sub, but most of the time if you're doing anything with any level of complexity you'll end up with several subs.

    BSB

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: More Efficient: Calling smaller macros or one Big macro?

    The modular approach is considered to be significantly better if your routine is really big - say several pages, because you can more easily isolate the trouble spots. With a routine that calls the same sequence for different values, you can use functions, subroutines or the little used and often spurned real subroutine the GoSub......Return feature
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: More Efficient: Calling smaller macros or one Big macro?

    I think one of the real "efficiencies" from a modular programming style is not so much how it helps the current project, but how it helps future projects. By the time I knew him, my mentor was not doing very much "novel" programming. Almost all of the programming he did was about combining his existing library of procedures in novel ways. Sometimes you want to "Call this, then call that, then call the other". Other times "call this, then call the other". If you've weaved everything together in a mass of spaghetti strings, it is difficult to pull out each thread and combine it differently.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: More Efficient: Calling smaller macros or one Big macro?

    oops wrong thread, please remove

  6. #6
    Registered User
    Join Date
    05-23-2018
    Location
    Texas, United States
    MS-Off Ver
    2013
    Posts
    39

    Re: More Efficient: Calling smaller macros or one Big macro?

    Thanks everyone for the input!

+ 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. Replies: 6
    Last Post: 12-17-2017, 02:35 PM
  2. [SOLVED] Error calling multiple Macros from Macro...
    By SUPPO_USN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2017, 12:17 PM
  3. [SOLVED] Macro to run 3 smaller Macros consecutively
    By Ramzes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2016, 11:59 AM
  4. [SOLVED] How to manage one macro recording three smaller macros (in addition to other commands)
    By Faintkitara in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2015, 04:33 PM
  5. Calling other macros within a macro
    By emacrohon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2013, 08:32 AM
  6. [SOLVED] Calling Macros from a Macro
    By Strup in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-11-2013, 04:46 AM
  7. 1 macro built of smaller macros
    By firefiend in forum Excel General
    Replies: 5
    Last Post: 02-09-2007, 03:55 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