Excel VBA Macros | Messages and variables exercise | Enter Dating Agency Details into Input Boxes

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 ==> Average difficulty
Subject ==> VBA training
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

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.

Open the WODA Application.xlsm file.  Your task is to create subroutines which can be attached to the two buttons on the application form.

Application form

The text on the buttons should provide a clue as to what they should do.


Create a subroutine which you can attach to the Add Details button.  A basic outline for this procedure could be:

  • Declare variables to hold each value the user will enter.
  • Use input boxes to ask the user to enter each value and capture the result in the variables you have declared.
  • Write the value of each variable into the appropriate cell on the worksheet.
  • Present a message which informs the user that the application is complete.

For reference, the code to capture the value of an input box is:

MyVariable = InputBox("Type something")

Right-click on the Add Details button and choose to assign the procedure you have written.

Click the button to check that the system works.

Input boxes

Type a value into each input box and click OK to see the next one.

At the end of the procedure, all of the cells should be filled in.

Final message

You can display a message to tell the user that the application is complete.

Now create a subroutine which you can attach to the Edit Details button.

This will be identical to the first subroutine except that you'll use the value of each cell to set the Default parameter of each input box.

Attach the subroutine to the Edit Details button.  Click the button to test that the system works.

Edit details

Each input box should appear with the current value already displayed.


Save and close the file.

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 1 thread Add post
19 Aug 19 at 02:58

What is the purpose of using variables at all here? Why not simply do something like:

Range("C4").Value = InputBox(Range("B4").Value) 

Thank you!    

19 Aug 19 at 08:15

I think the main answer to that is that this is an exercise designed to teach how to use variables!  But even were this not the case, it's often better to store intermediate values in variables, if nothing else because it makes it easier to debug code (you can inspect the value of variables to see if they're correctly set).  That said, if you're comfortable not using variables for this example, don't!