how to record a macro to click on "ok button" on a msg box


Hi guys,

Im recording a macro to copy paste data from wrkbook 2 into wrkbook 1.

But before i could copy the data, workbook2 has a pop up message box with a button "update data "----> followed by "continue button"

so  basically i have to click on the "update data" button once and "continue " button once before i could copy the data into workbook1.

How do i do that? I tried recording the macro to perform the clicking of Both buttons but it could not be recoded in the macro recording.

help me please




I believe this tutorial (one of ours) should tell you everything.

To summarize it, you could use a macro like this:

Sub button_action_msgbox()

response = MsgBox("Do you want to copy?", vbYesNo)

If response = 6 Then

    response_2 = MsgBox("Are you sure?", vbYesNo)

    If response_2 = 6 Then

        'Perform the copying

    End If

ElseIf response = 7 Then

    MsgBox "You clicked No"

End If

End Sub

I took example 4 from the linked tutorial above and added another level for the "confirm" message box.


Answer the Question

You must create an account to use the forum. Create an Account or Login