Office tutorials

Introduction to UserForm in Excel VBA

What is VBA UserForm 

The UserForm form is a form that works under Excel that allows us to create visually developed applications. You can add more types of controls to the UserForm form than to the data sheet. From the controls of the UserForm form, we can distinguish primarily:

  • Label label
  • TextBox text field
  • ComboBox combo box
  • ListBox list box
  • CheckBox checkbox
  • ToggleButton switch button
  • Frame frame
  • CommandButton command button
  • TabStrip change button
  • MultiPage application page
  • ScrollBar scroll bar
  • SpinButton knob button
  • Image Image

We learned some of the formulas in the previous part of our course. In the following chapters, we will only discuss controls specific to the UserForm form, and above all MultiPage.

 

How to insert UserForm?

The form is created in the VisualBasic Editor. In our VBAProjekt project, we select the UserForm object with the insert command. In this way, we have created a new form. We can refer to it in the VBA code using the name – in our case UserForm1.

 

Programming the UserForm

In the simplest way, we can program the UserForm form by clicking on the object in the Project pane. Then select the View Code element from the menu  . In the Code window, select the UserForm1 element. Then set the trigger for our form. The most commonly used trigger will be Initialize . This is where we will declare all activities performed when opening our form. We introduce here the definitions of such controls as the combo box or the list field.

 

Open UserForm when opening an Excel file

If we would like our form to run automatically when opening an Excel file, we should program the Ten_Carsoryt object or interchange the ThisWorkBook in the Project pane. We assign to it the code below. The form will open each time you open the file. We used the Show command to do this . From among the declarations, we choose Workbook . Of the triggers, choose Open .

1 comment

    • k188b on June 28, 2018 at 9:38 am

    Reply

    What’s up everyone, it’s my first visit at this site, and article is actually fruitful designed
    for me, keep up posting such content.

Leave a Reply

Your email address will not be published.