We’ve just managed to get ourselves started with user forms by inserting a new blank form. That first part was easy. Next we’re going to add some buttons to the user form.
Add an option button to the user form
Adding option buttons to the user form
Hopefully you’ve got the tool box showing:
If not, go “View” “Toolbox”. What we’re going to do is pick items from the toolbox and draw them on our blank user form template. You’ve got lots of choices there. Some experience, practise and playing around will help you discover what they all do (typing “Toolbox” into Excel VBA help will also give you your first clue about what all things in the toolbox might be able to do). For now, we’re going to concentrate on just one of them: the option button. Hover over the toolbox until you find the option button (second row, third one in). Click on the option button. Then move to your blank user form and draw the option button. Here’s a very short video that walks you through those exact steps.
Note you can copy the option button down, rename it and shuffle the option buttons around. This button is going to allow the user to choose how they would like the outputs of the macro presented.
Add a command button to the user form
Adding a command button
We’re also going to add a command button to our custom user form. When the user presses the command button the macro will proceed/ continue.
Find the command button from the tool box (second from bottom line, second one in) and draw it say in the bottom right hand corner of your user form.
Next: viewing user form macro code
What have we achieved so far? Well we’ve managed to:
- Insert a new custom user form
- Insert three option buttons (allowing the user to make some choices about how, in this case, they’d like the outputs presented)
- Insert a command button (which, when pressed, will ‘tell’ the macro to proceed with its calculations).
Next we’re going to get a sense of how the buttons we’ve just created might interact with our macro. Perhaps for the first time ever we’re going to view user form macro code.