+ Reply to Thread
Results 1 to 5 of 5

how do i break a large procedure

  1. #1
    Registered User
    Join Date
    11-06-2008
    Location
    nigeria
    Posts
    25

    how do i break a large procedure

    I have produce this spreadsheet, which is attached. it is for training needs in my company. if a name is clicked in column A it shows against a course scheduled for the individual and also transfer this info to a print page , which i have called Individual, and Individual 2.

    now i want to run the whole program but its giving me this compile error: Procedure too large. How can i break this procedue.

    I need help
    Attached Files Attached Files
    Last edited by VBA Noob; 11-28-2008 at 01:51 PM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening excel77
    Quote Originally Posted by excel77 View Post
    now i want to run the whole program but its giving me this compile error: Procedure too large. How can i break this procedue.
    I need help
    Your procedure is too large (that bit you already know) - the general advice for this is to break your code up into smaller modules and daisy chain them together.

    It's not an ideal answer, I know, but VBA's nor perfect and you've hit one of its limitations. the msdn page dealing with such a limitation is here - at least it tells you how big your app can be, so you can see where you've gone wrong for next time.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Wow, that's some procedure...I never knew that error message existed

    Seriously though you need to break that down. A quick glance shows that the With Worksheets(1)....End With instruction blocks are essentially the same, with only the Range address changing.

    Whenever you see constantly repeating instructions like that, it means it's crying out to have them eliminated and replaced with a loop inside which you have just one block of instructions. The paste destination ranges, (with a few odd exceptions which need to be examined) vary by one row and this could obviously be calculated from the value of the loop variable.

    I haven't looked at whether your approach is the most efficient. Can you expand on your brief description about what you want to achieve? There may be better ways, maybe not even involving macros.

    Rgds

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Excel77,

    We could answer your question faster if you would explain what you want the code to do. It looks like a simple search routine. A good explanation would help in rewriting the code in a faster and more efficient manner.

    Sinccerely,
    Leith Ross

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284
    I think your code is wrong too! You start in increments of 6 rows, then suddenly you increment by 7 at one point. And you skip rows in the target area.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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