+ Reply to Thread
Results 1 to 14 of 14

Procedure Too Large Error VBA

  1. #1
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Procedure Too Large Error VBA

    Hi,

    I hope someone can please help. I have a module with a lot of code that is causing me to get a Procedure too Large Error when I press a button to run the code.

    The code used is to transfer data from a selected Row in the Data Base sheet within the workbook to multiple Input sheets in the same workbook.

    Below is about half the code used in a module and as I am a newbe to VBA I am not sure how to "lighten" the code or other tricks that can be used in order for it to run properly.


    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    10-10-2015
    Location
    Hoboken, Antwerp, Belgium
    MS-Off Ver
    2010
    Posts
    93

    Re: Procedure Too Large Error VBA

    Is it possible to post an example of your workbook, with the entire code in it?
    Greetings,

    Cheetahke

  3. #3
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: Procedure Too Large Error VBA

    Hi Rudidw,

    One suggestion would be to break the sub into a few smaller subs and then make a new sub that calls each of them
    Please Login or Register  to view this content.
    There are 3 major but quick changes I would also suggest that will reduce the amount of coding and also improve the speed of execution.
    a) Use a variable fin place of 'ActiveCell.Row' as it appears to be the same thing on each line.
    b) Use the 'With Sheetname' structure on each group of instructions that refer to the same sheet at the start of the lines
    c) Use a variable in place of 'Sheets("PropDB") after the = sign on each row
    These changes are relatively easy to to using VBA's Find & Replace commands.

    Here's my adjusted coded for the part you supplied originally.
    (The bold and red colour are mine, for emphasis on the changes)

    Please Login or Register  to view this content.
    Last edited by StuCram; 10-14-2015 at 06:12 PM.
    If this has been helpful, please click on the star at the left.

  4. #4
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Procedure Too Large Error VBA

    Hi Cheetahke,

    Thanks for the quick reply. I have attached a sample workbook as requested.

    On the ProDB (Database) sheet you just need to click on a cell in column A and then click the button to run the macro (transfer data from this sheet to all the other sheets)
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Procedure Too Large Error VBA

    Hi StuCram,

    Thank you for you quick reply and adjusted code!

    Please advise how to break the sub into a few smaller subs and then make a new sub that calls each of them? As I said I am a newbe to VBA and I have no idea how to do what you suggested.

    I more or less understand your adjusted code and will give it a try!

  6. #6
    Registered User
    Join Date
    10-10-2015
    Location
    Hoboken, Antwerp, Belgium
    MS-Off Ver
    2010
    Posts
    93

    Re: Procedure Too Large Error VBA

    Is there any logic behind the numbers of the rows and columns, like a specific value in the cell on the database sheet?

  7. #7
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Procedure Too Large Error VBA

    Hi Cheetahke yes each row is a different project being analyzed, and each column contains a specific value used during the analysis of a project. All the values are stored on the database sheet for future reference or when a project needs to be re-analyzed due to environmental changes.

  8. #8
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Procedure Too Large Error VBA

    Hi StuCram,

    I was able to sit over the weekend with your suggested code and it works .... sort of.

    When I ran your code:
    Please Login or Register  to view this content.
    I received an error "Compile Error: Method or data member not found"

    The way I could get rid of the error message when running the macro was to change the code to:
    Please Login or Register  to view this content.
    My revised code (with your help) was now able to run the macro I did not get the original "Procedure Too Large" error!

    Do you have any idea why I received the Compile Error when I used your code?

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

    Re: Procedure Too Large Error VBA

    sPropDb should be declared as Worksheet not Sheets.
    If posting code please use code tags, see here.

  10. #10
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Procedure Too Large Error VBA

    Hi Norie,

    Thank you! The code now works 100%

  11. #11
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Procedure Too Large Error VBA

    To optimize the above VBA code for execution speed is which is better to use?

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.

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

    Re: Procedure Too Large Error VBA

    Don't think it makes a difference.

    Mind you, one thing you might want to do is specifically state .Value.
    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: Procedure Too Large Error VBA

    Sorry about that. My carelessness.

    My declaration was wrong:
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.
    I notice that user Norie already spotted that.
    Glad you found a solution.

  14. #14
    Forum Contributor
    Join Date
    07-13-2014
    Location
    Three Rivers
    MS-Off Ver
    365
    Posts
    127

    Re: Procedure Too Large Error VBA

    Thank you all for the help!

+ 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. [SOLVED] Compile Error: Procedure too large
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2018, 11:08 AM
  2. [SOLVED] Compile Error: Procedure Too Large
    By TLeng in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-29-2014, 02:16 PM
  3. [SOLVED] Procedure Too Large Error...
    By ekf23 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-11-2014, 10:53 AM
  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. 'Compile Error - Procedure Too Large'
    By nods in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 11-11-2010, 12:44 AM
  6. Error Message (Compile Error, Procedure too Large)
    By dreicer_Jarr in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 10-29-2010, 03:52 AM
  7. 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