Dialoge box in Excel

pts.
Tags:
Visual Basic
I have created a macro in excel and assigned it to a button. Now I need to ask a confirming question of the user, "do you want to ..." Then, based on the Yes or No answer, either perform the macro or cancel it. Also, does anyone know if you need to include personal.xls into the workbook in order to get a macro to work for users opening the file on the network?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Don’t assign the macro to the command button. Instead, right click on the command button and choose “View Code.” This will open the Microsoft Visual Basic window and start the code for the command button’s click event. The following code should do what you’re looking for:

Private Sub CommandButton1_Click

If MsgBox (“Do you want to run the macro?”, vbYesNo + vbQuestion) = vbYes Then
Application.Run (“Macro1″)
Else
Exit Sub
End If

End Sub

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following