+ Reply to Thread
Results 1 to 6 of 6

How to run one macro after another macro finishes

  1. #1
    Registered User
    Join Date
    07-19-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    How to run one macro after another macro finishes

    I have created a form in excel/vba/sql that refreshes several queries and then copies and paste values that information into another spreadsheet. The problem is that the macro will copy and past special the data before the refresh macro finishes. Is there a way to execute one macro after the previous macro finishes? I added an this code [Application.Wait Now + TimeValue("00:02:00") ] to the macro but it is not working the way I had hoped. It seems like this just stops all of the macros, not just one macro.

    Here is the code for the two macros:

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Last edited by arlu1201; 08-28-2012 at 09:16 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to run one macro after another macro finishes

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    07-19-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: How to run one macro after another macro finishes

    Thank you for bringing that to my attention.
    Last edited by Cutter; 08-29-2012 at 01:01 PM. Reason: Removed whole post quote

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to run one macro after another macro finishes

    make sure that the queries are set to not refresh in the background and then you can just call one macro after the other
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    07-19-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: How to run one macro after another macro finishes

    That seems to solve this issue. I used the following code. Thanks for the help!

    Please Login or Register  to view this content.
    I also removed this code from the first macro.

    Please Login or Register  to view this content.
    Last edited by alrichar; 08-29-2012 at 09:53 AM.

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How to run one macro after another macro finishes

    @ alrichar

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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