Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm sure you are not an idiot; just a newbee to VBA.
O.K. there are 2 types of controls. One type is the Forms Controls and the other is ActiveX controls. Both are almost identical in their purpose but they operate differently. ActiveX controls are the later technology and I think that the Forms controls are only there to keep xl backward compatible. I think that ActiveX controls started with xl2000 but Ill stand correcting on that but they have certainly been around since xl2002. In xl 2007 you will see both types in the drop down when you click on Insert Controls. In earlier versions of xl, to see the Forms controls, you need the Forms tool bar visible. To see the ActiveX controls you need the Control Toolbox tool bar visible. I just tested your code and it appears that you have created your List Box from the Forms tool bar and of course the code is for ActiveX controls and does not work on on Forms Controls. There are a number of advantages to using the ActiveX controls so rather than alter the code to work with Forms controls Ill try to explain how to create an ActiveX control and set its properties. Click on the List box icon and then on the worksheet and drag the list box out to the required size. (Same as for the Forms controls). Note the icon on the toolbar that looks like a blue set square, pencil and ruler. It is called Design Mode. It automatically turns on when you create the list box but more on Design Mode later. Right click on the list box after you have set its size (Note Design Mode needs to be on) and then select Properties. The top of the list is the list box name which is user changeable. It is this name which you use to refer to the control throughout your VBA code. Check out the other properties including Multi select. Before you can use the list box, turn off Design Mode. (Click on the icon.). Now at any time you want to make changes to the properties, you need to turn design mode on. Now turn design mode on and this time when you right click, select View Code. The VBA editor will open and place a private sub name and end sub. Note in the Project explorer that the code is attached to the Sheet name on which the list box has been inserted. Code that you want to run when the user selects a value in the list box is inserted here. However, it does not operate with multi list boxes because it would not know when the user has finished selecting. The code you have for multi select can be in a Module. Try the above and get back to me if you have any further questions. Also what version of xl you are using? (It is a good idea to always include it on requests to this forum.) Regards, OssieMac |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
userform listbox cannot get listbox.value to transfer back to main sub | Excel Programming | |||
avoiding duplicates in listbox (added from another listbox) | Excel Programming | |||
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) | Excel Programming | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming | |||
Is refreshing listbox rowsource in listbox click event possible? | Excel Programming |