Last Updated on January 11, 2023 by token
Inserting a ListBox list box (ActiveX control)
The list box, unlike the combo box, allows us to select more than one selection option at the same time. How do I insert a ListBox list field? As in the case of previous controls, we enter the Developer tab. We choose among ActiveX controls list box. We place them above the “Contact type” column. The list box in the VBA Editor is very similar to the combo box. The field can also be programmed so that the user can select only one selection option.
Programming the ListBox list box (ActiveX control) – single selection
Our table already has a list box. The list field is set by default in a way that only one selection option can be selected. The field programming itself is done in the VBA Editor in the ” This_Workbook” object . In our case, we would like to see the values for the contact in the list field: personal, telephone, e-mail. We save it in the following way:
With Sheet1.ListBox1 .AddItem "Face" .AddItem "Phone" .AddItem "Mail" End With
How do I get values from the ListBox VBA list box?
At the moment, we can choose any one value from the list box. To connect the list field with our application for entering data, we proceed in the same way as in the previous chapters. We update the “Sheet1” object by the following line of code