+ Reply to Thread
Results 1 to 7 of 7

Compile Error: Procedure too large

  1. #1
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Compile Error: Procedure too large

    Hi Forum,

    After adding some additional code to a change procedure on a userform, I'm getting a "Compile Error: Procedure too large". I realize this is due to the single procedure exceeding the 64kb size limit, however I'm unsure what the best way to split apart the procedure or reduce redundancy within the procedure to reduce the size. The procedure code in question is attached below as a .docx (due to the size of the procedure). Basically I have a dropdown list containing study ID's. Based on what is chosen in the dropdown list, the rest of the variables throughout the userform are populated with the corresponding data. Please let me know if you have any suggestions! Thanks!!

    cboStudyID_Change().docx

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: Compile Error: Procedure too large

    I'm getting "File corrupt" error
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Compile Error: Procedure too large

    Hey Special-K,

    Thanks for checking in & sorry about the "file corrupt" error. Try this file Private Sub cboStudyID.docx

  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: Compile Error: Procedure too large

    You could set a range variable:

    Set r = Range("StudyID")

    then replace

    txtEnrollmentDate = Range(strNamedRange).Cells(iRow, 2)

    with

    txtEnrollmentDate = r.Cells(iRow, 2)

    Constructs of this form

    If cboPrenatalCare_Intake.Value = "Yes" Then cbxPrenatalCare_IntakeYes.Value = True Else cbxPrenatalCare_IntakeYes.Value = False

    ... could be replaced with

    cbxPrenatalCare_IntakeYes.Value = cboPrenatalCare_Intake.Value = "Yes"
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    01-20-2013
    Location
    Denver, Colorado
    MS-Off Ver
    2011 (mac)
    Posts
    48

    Re: Compile Error: Procedure too large

    Quote Originally Posted by shg View Post
    You could set a range variable:

    Set r = Range("StudyID")
    Thanks, shg! I just went through and edited my code... It's now running without error! I appreciate your help!!

  6. #6
    Registered User
    Join Date
    05-11-2018
    Location
    Trinidad
    MS-Off Ver
    2013
    Posts
    9

    Re: Compile Error: Procedure too large

    Novice.

    Some advice how to break this down please:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$BA$4" Then
    Shapes("A 1").Width = Target.Value * Range("BA157")
    End If
    If Target.Address = "$BB$4" Then
    Shapes("A 1").Height = Target.Value * Range("BA159")
    End If
    If Target.Address = "$BA$5" Then
    Shapes("A 2").Width = Target.Value * Range("BA157")
    End If
    If Target.Address = "$BB$5" Then
    Shapes("A 2").Height = Target.Value * Range("BA159")
    End If
    If Target.Address = "$BA$6" Then
    Shapes("A 3").Width = Target.Value * Range("BA157")
    End If
    If Target.Address = "$BB$6" Then
    Shapes("A 3").Height = Target.Value * Range("BA159")
    End If
    If Target.Address = "$BA$7" Then
    Shapes("A 4").Width = Target.Value * Range("BA157")
    End If
    If Target.Address = "$BB$7" Then
    Shapes("A 4").Height = Target.Value * Range("BA159")
    End If
    If Target.Address = "$BA$8" Then
    Shapes("A 5").Width = Target.Value * Range("BA157")
    End If
    If Target.Address = "$BB$8" Then
    Shapes("A 5").Height = Target.Value * Range("BA159")
    End If


    Thanks.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Compile Error: Procedure too large

    Chris-B. welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

    Also, please use code tags when posting code (see my footnote, below).

    Also, explain what you want, please
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. Compile Error: Procedure too Large
    By tarab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2013, 05:43 PM
  3. 'Compile Error - Procedure Too Large'
    By nods in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 11-11-2010, 12:44 AM
  4. [SOLVED] Compile error: Procedure too large
    By BHARATH RAJAMANI in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2005, 06:05 PM
  5. Re: Compile error: Procedure too large
    By Susan Hayes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2005, 12:06 PM

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