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
Bookmarks