+ Reply to Thread
Results 1 to 6 of 6

assistance with VBA procedure being too long

  1. #1
    Registered User
    Join Date
    04-29-2016
    Location
    Gilbert, Az
    MS-Off Ver
    MS 2010
    Posts
    23

    assistance with VBA procedure being too long

    so this is slightly complicated I have a worksheet named "Agents" range (A2:A21) you can enter names . I have a command button that has a macro that will create tabs based on the names entered into the range. Now I also have a worksheet "Overview" thats has the same Agent names range(B50:B69) from the Agent tab with a active X control combobox that has Jan - Dec. when you select from the drop down it should pull data from the each of the created tabs Example worksheet (Template) Range (L12:P23)

    So based on the drop down (Teamrecbox) value in the worksheet "Overview" it needs to pull the corresponding data from each of the tabs that will be created - I wrote out the code the long way but now the procedure is too long.. any assistance I can get will be amazing

    I've included a copy of my workbook
    Last edited by Sway2119; 04-17-2017 at 12:40 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: assistance with VBA procedure being too long

    Wow

    This is gong to take a lot of time.

    Please Login or Register  to view this content.
    Can be replaced with

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 04-15-2017 at 05:48 PM. Reason: Code Revised.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    04-29-2016
    Location
    Gilbert, Az
    MS-Off Ver
    MS 2010
    Posts
    23

    Re: assistance with VBA procedure being too long

    believe me it's been the BANE of my existence. I had it set up another way by agent but I was told that it needed to be a high overview of all agents at once.

  4. #4
    Registered User
    Join Date
    04-29-2016
    Location
    Gilbert, Az
    MS-Off Ver
    MS 2010
    Posts
    23

    Re: assistance with VBA procedure being too long

    here is a sample of the code I'm referring to, I have it written out for all possible tabs so it goes to Agent 20, then repeats based on the next value for the teamrecbox.
    Please Login or Register  to view this content.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: assistance with VBA procedure being too long

    Hi Sway,

    How about using loops to do the work above. Like:
    Please Login or Register  to view this content.
    I'm also a little worried about your code being behind a worksheet instead of in a module. The scope of code behind a worksheet should only be in that worksheet. If you want your code to deal with all those other sheets you should have it in a Module. See:
    http://www.cpearson.com/excel/Scope.aspx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: assistance with VBA procedure being too long

    Your DropDown404_Change macro can be reduced to:


    Please Login or Register  to view this content.
    Your teamrecbox.Change Macro can be reduced to:

    Please Login or Register  to view this content.

    Your AddButton_Click macro can be reduced to:



    Please Login or Register  to view this content.
    If a month is always selected and recselectbox is never empty then it might even be reduced to:


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 04-15-2017 at 08:47 PM.

+ 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] Procedure too long
    By Littlesimon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-15-2016, 08:02 PM
  2. some assistance adding days to long date format
    By dan_fash in forum Excel General
    Replies: 2
    Last Post: 04-10-2015, 04:10 PM
  3. [SOLVED] Procedure too long error, help with breaking down or optimizing a macro
    By dreddster in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 02-19-2015, 12:00 PM
  4. VBA Ok Click() If Statement Procedure Too Long
    By LukeAM in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2014, 06:59 AM
  5. [SOLVED] Help needed simplifying code as procedure to long
    By johnny_p in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-28-2014, 10:55 AM
  6. Excel 2010: Macro Error 'Procedure Too Long'
    By marthadanielle in forum Excel General
    Replies: 4
    Last Post: 04-13-2012, 07:15 AM
  7. Procedure Too Long
    By Nick3535 in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 10-08-2010, 09:02 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