For every event associated with an object VBA has set up a mini procedure called event handlers that respond to the event. These are the Sub and End Sub statements you see at the start and end of your code. You add in your own VBA statements in-between these statements to specify how the event is to proceed.
To define an event handler for a form:
1. Select which form you want
2. Then display the code module
3. Select your desired event from the procedure list
4. Enter the rest of the procedure between the Sub and End Sub statements.
Below you will see a code module for the form object, you should notice that UserForm has been selected by default in the Object List and the Click procedure is currently active in the module. The screen shot also shows you a portion of the events recognised by the UserForm object.
Procedure List – This will show you which procedure is active in the code module. If you have selected (General) then it will display all the standard VBA procedures and functions. If you have chosen something different like the example above then it will show you all the events recognized by the object.