Program code -- the statements that tell the program what to do - is contained in the Code window of the VBA IDE. It can be displayed any of the following methods:
- From the View menu in VBA, click Code.
- Press the F7 key.
- Double-click any control on a UserForm.
Once inside the Code window, you can create code by typing in VBA statements, copying and pasting code from other sources, or using Intellisense to place items. If you open the Code window by double-clicking a control that has no code yet associated with it, the first and last lines of a subroutine are created for the control, such as the following lines for a command button:
Private Sub CommandButton1_Click()
Tell me about...
Adding Controls to a UserForm