+ Reply to Thread
Results 1 to 3 of 3

Repeat part of the macro

  1. #1
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58

    Repeat part of the macro

    Hi guys,

    is it possible to repeat part of (but not all of) the macro from within the macro itself?

    I am moving blocks of 25 lines from one document to another. What I would like, is at some point in the macro have a point (HERE) where the repetition would begin. I would then have the command to find and collect the 25 lines and directly below would like to put: if there is data below these 25 lines, go back to HERE. I've got the if part and the moving part, but don't know if there is a command to repeat or go back to a certain part of the macro.

    Does anybody know if this is possible?

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Perhaps a Do-Loop - search the forums or google for examples, come back with specifics if necessary.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    VBA has lots of flow control structures. The only one I'd recommend you not use is the GoTo statement -- it makes code hard to maintain.

    You code put the code to be repeated in a separate sub and pass the necessary variables, or have the code segment in the same macro and use GoSub.

+ 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