1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Excel Macros too large problem

Discussion in 'Business Applications' started by theseus75, Jun 24, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. theseus75

    theseus75 Thread Starter

    Joined:
    Jan 7, 2005
    Messages:
    275
    I've recorded and combined a few macros into one and - while it is really large - I never thought anything of it until I got the following error while trying to run it:

    "Compile Error
    Procedure too large"

    I can certainly split these up into separate procedures, but it would save time to have them all as one. Is there a way to override this error?

    I am using Windows XP w/ SP2 and Excel 2003.

    Thanks in advance for any help.
     
  2. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,840
    It is probably quite possible that you can considerably reduce the size of the Macro by rewriting it. Recorded Macros are notorious for having superfluous code in them. ;)
    If you post it I am sure that one of the Excel gurus can rewrite it for you, or at least point you in right direction. :)
     
  3. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Break the large macro into seperate subs and then call each of the separate subs from your main procedure. Doing it this way makes your code much easier to maintain and you can still execute all the code by running your main macro only.

    If you need more help please post your sample workbook or code and we'll take a look and offer more advice.

    Code:
    Sub MainMacro()
    Call Macro1
    Call Macro2
    Call Macro3
    End Sub
    
    
    Sub Macro1()
    'Your Code
    'Your Code
    End Sub
    
    Sub Macro2()
    'Your Code
    'Your Code
    End Sub
    
    Sub Macro3()
    'Your Code
    'Your Code
    End Sub
    
    
    Regards,
    Rollin
     
  4. theseus75

    theseus75 Thread Starter

    Joined:
    Jan 7, 2005
    Messages:
    275
    Thanks for the help: that code worked perfectly, Rollin_Again.
    OBP: Yeah, I'm sure my code has plenty of little extras, but the Call method seemed to take care of it. One of these days I'll get around to cleaning them up a bit. :)
    Thanks again!
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/724207

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice