+ Reply to Thread
Results 1 to 8 of 8

Compile Error: Procedure Too Large

  1. #1
    Registered User
    Join Date
    08-07-2014
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    22

    Compile Error: Procedure Too Large

    My code returned a compile error saying my procedure was too large. I looked online and found that my code needs to be smaller than 64 kb in size. How do you find the size of your code and does anyone have suggestions on removing some of the redundancy from the code below to reduce the size? The code is repeated about 60 times so that's creates about 4500 lines of code.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Compile Error: Procedure Too Large

    You don't really need all those variables for ranges.

    For example this,
    Please Login or Register  to view this content.
    could be rewritten as this.
    Please Login or Register  to view this content.
    That cuts the length of that particular code in half and since you have similar code throughout making similar changes is going to cut the length of the entire code considerably.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-07-2014
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    22

    Re: Compile Error: Procedure Too Large

    Norie, thank you for the help with the code. I changed the code to what is shown below, which removed a few lines. It is still returning the error about the procedure being too large. Is it normal to split up something that repeats like this into separate functions?

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Compile Error: Procedure Too Large

    Did you change all the code like that?

    Also, I notice you've added comments, on separate lines, to the code - why?

    If you want to add comments try putting them on the same line after the code.

  5. #5
    Registered User
    Join Date
    08-07-2014
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    22

    Re: Compile Error: Procedure Too Large

    I made the changes throughout the code. I tried to include comments to make it easier for someone to check my work since I'm going to share this with other people at work. If the comments take up too much memory, than your idea sounds better to have the comments in one spot since it is repetitive. I give that a try and let you know how it goes.

  6. #6
    Registered User
    Join Date
    08-07-2014
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    22

    Re: Compile Error: Procedure Too Large

    "I'll" give that a try.

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Compile Error: Procedure Too Large

    This is not tested but will show how to use loops:

    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  8. #8
    Registered User
    Join Date
    08-07-2014
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    22

    Re: Compile Error: Procedure Too Large

    Izandol, that was a pretty handy code. I had to do a little modification to my worksheet, but it looks like it is working. It took my 4500 lines of code down to under 100! I was wondering if there is a way to end the code early? Right now it is stepping through from 1 to 20, but there are going to be times when all 20 runs won't be needed. I don't know if you opened my original spreadsheet, but it depends on some input from the user in columns I and J. If I have blank cells in those columns, it gives me an error of "Object Variable not set" since it is looking for a value that hasn't been entered in. Norie and Izandol, thank you both for your help.

  9. #9
    Registered User
    Join Date
    08-07-2014
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    22

    Re: Compile Error: Procedure Too Large

    I think I have it worked out now. I haded another If statement to end the function if no values are added. The modified code is below.

    Please Login or Register  to view this content.

+ 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. Compile Error: Procedure too large
    By cispus78 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-25-2015, 07:38 AM
  2. [SOLVED] Compile error: Procedure too large
    By Mecha_Trueno in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-12-2014, 08:45 AM
  3. Compile Error: Procedure too Large
    By tarab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2013, 05:43 PM
  4. Compile error: Procedure too large
    By Knitty in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 03-04-2011, 06:52 PM
  5. VBA Compile error: Procedure too large?
    By Jerry Dyben in forum Excel General
    Replies: 1
    Last Post: 10-31-2005, 07:05 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