我已经在单击按钮时按程序创建的一系列单元格中添加了3列列表框。列表框是3列并且包含大量数据,因此我使用GotFocus()和LostFocus()来展开和折叠它们以便所有项目都可见,但这是我手动创建的列表框。如何让生成的Listbox具有此行为?
Public Sub CreateListbox()
Dim rCell As Range
Dim rRng As Range
Set rRng = ActiveSheet.Range("AA3:AA45")
For Each rCell In rRng.Cells
Set oLISTBOX = ActiveSheet.OLEObjects.Add(classtype:="Forms.ListBox.1")
With oLISTBOX
.Object.IntegralHeight = False
.Object.Font.Size = 11
.Top = rCell.Top
.Left = rCell.Left
.Width = rCell.Width
.Height = rCell.Height
.LinkedCell = rCell.Address
.ListFillRange = "ValSocDeterm."
.Object.ColumnCount = 3
.MultiSelect = 1
End With
Next rCell
End Sub