View user form code

We’ve just managed to add option buttons to a user form. Now we’re going to look at the extra code that’s been created by adding the buttons.

View the user form code

Viewing macro user form code

We’ve been busy working with our own custom user form:

Now (from the menu in your VBA editor) go “View” “Code”. You should be able to find some new menu items that relate to the buttons you’ve just created:

Click on each of the menu items in turn. You should notice some new lines of code appear like so:

Save your work now. If you’ve got a bit lost, we’ve made the example available for you to download: custom user form macro v1. It’s not working yet, so don’t worry about any errors you get, we’ll fix them at the next stages.

Each button we’ve placed on the user form has its own macro code attached (a macro within a macro, a module within a module, a routine within a routine). If we want to (and we don’t always want to), we can use each button to make something happen inside our ‘big’/ ‘main’ macro.

Structuring the macro code

What we’re going to do next is think very carefully about how we want our macro to work and what we want the macro to do (if anything) when the user clicks on a button. We’re going to need to think about how we structure the user form macro code.

About this online Excel course material

You’re looking at a free online course extract covering different kinds of Excel VBA macro dialog boxes and user forms.

...join the conversation...

Your email address will not be published. Required fields are marked *