Multi Select List Box - Checkbox
I think there are 3 different answers to your question because I'm not sure
where the code is located and which type form you are refereing to.
there are two different type forms, one is a worksheet and the other is the
VBA Userform. I suspect you are using the VBA form where you may need to
reference the form name as well as the listbox name.
1) You may not have the right sheet name or listbox name. The names of the
listbox can be renamed from the property window or through code. If you are
in a worksheet you need to get into Design Mode and right click the Listbox
to changge names or check the name.
enter Design Mode by the following
a) worksheet menu View - toolbars - Control Toolbox. click on the
Triangle to enter or exit design Mode
2) Check the properties of a VBA form. From VBA menu View - Properties
Window. Check name property. by the way you can manually vchange the List
box Multiselect property from the property window on wither the worksheet of
the VBA form property.
3) I think your problem if you are using worksheet VBA code, then you need
to use
Userform1.Listbox1.MultiSelect = fmMultiSelect
You can put initialization code for a listbox in the initilization code for
the userform
Private Sub UserForm_Initialize()
UserForm1.lstNames.AddItem "Test One"
UserForm1.lstNames.AddItem "Test Two"
UserForm1.txtUserName.Text = "Default Name"
End Sub
when the code say private it means it has to be inside the userform. If you
right click the userform in VBA and select view code is where you want to put
this code. A private function in a userform will recognize Listbox1 without
needing the Userform1 because the Listbox is part of the Userform. if you
are using two userforms then if you are referencing the 2nd Userfrom list box
from the first you need to include the Userform Name. The Userfrom Names are
not private because they need to be recognized from the worksheet put the
control objects in the form are usually private.
"Paul" wrote:
Ah ! I've tried using this format of code in the Initialisation code of a
form, but it keeps failing with a message 'Member of data member not found'
Is this a case of not having the code run in the right place ? If so, what
is the right place ?
"Joel" wrote:
Private Sub CheckBox1_Click()
ActiveSheet.ListBox1.MultiSelect = fmMultiSelectMulti
End Sub
"Paul" wrote:
I want to make my list box available for multi selection using checkboxes - I
know it must be easy, but I'm having a bad day and can't work it out.
|