Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have some vba subs that perform various data import and sorting. Now that the individual subs are tested and functioning independently, is there a command string that can be put in a new sub that allows linking the subs to call/run one after another? Wanting to avoid copy/paste all code from each sub into a single large sub.

    Private sub xx
    Run Private sub 45
    Run Private sub 53
    Run Private sub 62
    Run...........

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='pillarcas' post='765330' date='13-Mar-2009 23:59'][/quote]
    Just call them with there name one after one
    Sub xx()
    Mysub1()
    Mysub2()
    Mysub3()
    End Sub
    This will work if you subxx is in the same module as the other subs.
    If you want to call them from another module, don't declare your sub's Private.
    Francois

  3. #3
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Not clear on MySub command usage. The subs are named

    Private Sub Command68_Click()
    Private Sub Command57_Click()
    Private Sub Command72_Click()

    Not sure how to merge the mysub with the name.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Let's say that you place a new command button cmdCombine on the form that should have the same effect when clicked as clicking Command68, Command57 and Command72.

    You can do this by creating the following On Click event procedure for cmdCombine:

    Private Sub cmdCombine_Click()
    Call Command68_Click
    Call Command57_Click
    Call Command72_Click
    End Sub

    You can omit the keyword Call if you prefer.

  5. #5
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you, that works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •