Introduction to ActiveX controls in Excel VBA

Introduction to ActiveX controls

It’s nice that you have already reached this part of the training :). VBA ActiveX controls are controls by means of which we can visualize our applications in Excel. ActiveX controls available in the Developer tab are used primarily to build simple applications running under Excel. For the construction of slightly more difficult applications, we will use UserForm forms available in the VisualBasic Editor. To use the ActiveX controls in Excel, we enter the Developer tab , then Insert> ActiveX controls. Remember to not confuse these controls with the form controls.

If we would like to build a more complicated application, eg using the UserForm form. We enter the VisualBasic Editor. In the Project window, click on the insert select UserForm . Then, to the inserted form in this way, we can already introduce our controls using the ToolBox window .


Types of ActiveX controls

You can assign VBA code to each of these controls, not just the macro from the module as it is in the case of form controls. Among the most popular ActiveX controls, we distinguish:

  • Label
  • CommandButton
  • TextBox
  • ComboBox
  • ListBox
  • CheckBox
  • OptionButton / RadioButton
  • ScrollBar
  • SpinButton
  • Image
  • Application page tabs (MultiPage)
  • TabStrip


Triggers ActiveX controls

In the previous section, I described an example of running a simple program by simply clicking the CommandButton button . In this case, one click is the triggering of our program – it runs it. In VBA in Excel, we can also define other triggers for our programs. This can be, for example, a double-click, an error, hovering over a button. Triggers are defined by double clicking on our button in design mode.


Properties of ActiveX controls

Each control in Excel VBA has its own properties. We can use them to set parameters such as position, font, colors, etc. Below is a list and description of the CommandButton control properties:

Leave a comment

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

%d bloggers like this: