ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiselect listbox with check boxes (https://www.excelbanter.com/excel-programming/326561-multiselect-listbox-check-boxes.html)

Kandi

Multiselect listbox with check boxes
 
The code below creates a multiselectable listbox with check boxes linked to a
named range. The code creates the box. However, you cannot select the box
or any of the checkboxes.
There are two ways around this problem. Either turn on and off design mode
OR select another worksheet then select the worksheet with the listbox.

Is this a bug or did I leave something out? This does not seem like normal
behavior. It almost seems as if the items are locked or disabled. I am
using Office 2003 and tried different computers to make sure is was not a
software issue.


Sub test()
lbdoawidth = 100
lbdoaover = 250
lbdoafromtop = 75
lbdoaheight = 75
lbdoadropdownlns = 7
x = 1
incremental = 100
' create listbox and populate with named range. Check boxes and multi
select enabled

Sheets("sheet3").OLEObjects.Add(ClassType:="Forms. ListBox.1", Link:=False, _
DisplayAsIcon:=False, Left:=lbdoaover, Top:=(lbdoafromtop +
incremental), Width:=lbdoawidth, Height:= _
lbdoaheight).Select
selectionname = "lbdoa" & x
With Selection
.Name = "lbdoa" & x
.ListFillRange = "expdoa"
End With
'ActiveSheet.OLEObjects(selectionname).Object.Mult iSelect = fmMultiSelectMulti
ActiveSheet.OLEObjects(selectionname).Object.Multi Select = 1
ActiveSheet.OLEObjects(selectionname).Object.ListS tyle = fmListStyleOption
ActiveSheet.OLEObjects(selectionname).Object.Bound Column = 1
ActiveSheet.OLEObjects(selectionname).Object.Colum nCount = 1
ActiveSheet.OLEObjects(selectionname).Object.Enabl ed = True
End Sub


All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com