How to automatically close a messagebox in vba

  • I've got a Macro that I'm working on where depending on what project we are doing, it will format the pages a certain way. After I format it, I use the macro to copy and paste the info across other sheets in the same workbook. Those cells already have data in them.
    The box that pops up says "there is data already here. do you want to replace" options are "yes" or "no". If I want it to select yes automatically, is there a way to do that in the code?

  • Okay I got it. I used the following
    [VBA]
    Application.DisplayAlerts = False
    Range("A8:P29").Select
    Selection.Copy
    Sheets("Room Inital Component Sheet").Select
    Range("A8:E8").Select
    ActiveSheet.Paste
    Sheets("Room Final Component Sheet").Select
    Range("A8:E8").Select
    ActiveSheet.Paste
    Application.DisplayAlerts = True[/VBA]

  • sub forAutocloseMsgbox()
    Application.ScreenUpdating = True
    On Error Resume Next
    ActiveWorkbook.Save
    Dim AckTime As Integer, InfoBox As Object
    Set InfoBox = CreateObject("WScript.Shell")
    'Set the message box to close after 10 seconds

    AckTime = 4
    Select Case InfoBox.Popup("Done !! Click OK " & Chr(13) & Chr(13), _
    AckTime, "RV 7383423400", 0)
    Case 1, -1
    Exit Sub
    End Select
    end sub