View Full Version : listbox usage in vba

10-14-2010, 11:16 PM
I have a sample VBA application, where in a dropdown gets populated dynamically.
hence I am not able to view the items in the dropdown completely.
Can you suggest & clarify a few doubts of mine regarding the same.
Q1. Usage of which component is better in the above scenario.i.e a listbox or a dropdown(ActiveX-control).
Q2. Assuming that usage of listbox is a good design option, How can i name a listbox?
Q3. What are the events that can be associated with the value change of the listbox.

Anticipating the favorable reply at the earliest.

Kenneth Hobs
10-15-2010, 05:49 AM
A1. By dropdown, I think that you mean ComboBox. If you have that many items then a listbox might not show all either.

A2. You can name it in 4 ways at least. (1) Use the name box just as you would for any range name when it is selected in Design Mode. (2) Right click in Design Mode and select Properties and change the name there. (3) Right click the sheet's tab with the code and View Code or open the VBE and select that sheet object in the Project Explorer. Press F4 to view the properties or by menus View > Properties Window and set the name as in step (2). (4) Use a macro method.

A3. Right click the sheet's tab with the code and View Code. Select the control from the dropdown list. Select events from the other dropdown list.