Results 1 to 6 of 6

How to run one macro after another macro finishes

Threaded View

  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:

    Sub Update_Database2()
    '
    ' Update_Database2 Macro
    '
        answer = MsgBox("Would you like to Update this report.  This update will take a few minutes - Update the data now?", vbYesNo)
        
        If answer = vbNo Then Exit Sub
        If answer = vbYes Then Call Refresh_All
        Application.Wait Now + TimeValue("00:02:00")
        Call Update2
    '
    End Sub

    Sub Update2()
    '
    ' Update2 Macro
    '
    
    '
        Application.ScreenUpdating = False
        Sheets("Sheet 1").Select
        Sheets("Sheet 2").Visible = True
        Sheets("Sheet 2").Select
        Range("tbl_table_1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet 1").Select
        Range("A14").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Sheet 2").Select
        ActiveWindow.SelectedSheets.Visible = False
        Sheets("Sheet 1").Select
        MsgBox "The Update is Complete"
    End Sub
    Last edited by arlu1201; 08-28-2012 at 09:16 AM.

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