Excel VBA Macros | Messages and variables exercise | Using MSGBOX to ask whether to show answer

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Software ==> Excel VBA Macros  (52 exercises)
Version ==> Any version of Excel
Topic ==> Messages and variables  (4 exercises)
Level ==> Harder than average
Subject ==> VBA training

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a new workbook, and type 42 into cell A1 and press Enter.  This is the answer.

Select a different cell on a different sheet.

Create a macro which will take you to the answer IF you want to see it.  Your macro should first create a variable and then use the MsgBox function to ask whether you want to see the answer:

Excel VBA Macros exercise - Messages and variables (image 1)

Note that by default we have made sure that the second (NO) button is the one selected

You will probably find the courseware manual section on the MsgBox function useful for this exercise.

Your macro should now select the answer on the correct worksheet if your user chooses Yes, or display the following message otherwise:

Excel VBA Macros exercise - Messages and variables (image 2)

This is included just so something happens in either eventuality

Save this workbook as Example of Continue Question, then close it down.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post