+ Reply to Thread
Results 1 to 4 of 4

Repeating a specific macro over subsequent lines

  1. #1
    Registered User
    Join Date
    03-04-2009
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Repeating a specific macro over subsequent lines

    Hi All,

    I have created a macro which will run over a specific range of data (i.e. lines 5-13). It involves changing the format and layout of tab-delimited cell content.

    The output files I'm working with involved a series of repeated outputs which are different from each other and I would like to repeat this same macro for each subsequent section to the bottom of the Excel form (i.e. macro is currently running over lines 5-13, but would also like to repeat it for lines 15-23, 25-33, 35-43, 45-53, etc).

    The current macro in use over lines 5-13 is currently 13 pages long in a Word document, size 12 font, so if possible, I would like to just repeat it for each subsequent section, rather than rewrite it. In some cases there will be up to 35 sections below the first, each 9 lines long.

    I would appreciate any help that can be provided. Thanks.
    Last edited by VBA Noob; 03-04-2009 at 05:25 PM.

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

    Re: Repeating a specific macro over subsequent lines

    Hello stepheng2383,

    Welcome to the Forum!

    Is your question about an Excel or a Word?
    The current macro in use over lines 5-13 is currently 13 pages long in a Word document, size 12 font, so if possible, I would like to just repeat it for each subsequent section, rather than rewrite it. In some cases there will be up to 35 sections below the first, each 9 lines long.
    You should also post the macro code.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Repeating a specific macro over subsequent lines

    You may have to take the code you have and change all references to the range to variables, then you can just repeat the sub you have for different ranges.

    As an example if you have:
    Please Login or Register  to view this content.
    instead put
    Please Login or Register  to view this content.
    Then you can add whichever rate ranges you want to do it over.
    Dave

  4. #4
    Registered User
    Join Date
    03-04-2009
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Repeating a specific macro over subsequent lines

    In response, this post is referring to Excel. Also, davegugg, one is I encountered with replacing specific numbers (in reference to row numbers), was the it would replace all numbers, include those referencing colors. In essence, this would change all the colors being formatted through the macro as well.

    The code is as follows:
    Please Login or Register  to view this content.
    [Note: This is just an example of the start of the code, as it ran 11,000 characters over the length of the available posting space; the remaining has been cut]

    I'm sure this could be cleaned up quite a bit as well and now, after copying these down more than three times, I run into a "Compile Error: Procedure too large" error. If anyone has any spots that can be cleaned up, this would be helpful as well. Remember, I'm trying to copy this macro, which affects row 5 through row 13, over additional selections; row 15 through row 23, row 25 through row 33, etc.

    Thanks guys!
    Last edited by Leith Ross; 03-04-2009 at 08:04 PM. Reason: Added Code Tags

+ 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