1 '添加条目 RowSource 2 Private Sub UserForm_Initialize() 3 Range("a1:a10").Name = "DataSource" 4 Me.lbx.RowSource = "DataSource" 'Rowsourse = string 5 End Sub
1 ' adding an entry the Additem 2 Private Sub UserForm_Initialize () . 3 Dim the I & . 4 With Me .lbx . 5 .RowSource = "" ' not empty this denial of permission . 6 the For the I = 1 the To 10 . 7 .AddItem Cells (the I, 1 ). the Value, the I - . 1 ' the AddItem [Item [, varIndex]] index starts from 0, -1 unchecked . 8 the Next the I . 9 End With 10 End Sub
1 '添加条目 List 2 Private Sub UserForm_Initialize() 3 Me.lbx.List = Application.WorksheetFunction.Transpose(Range("a1:a10").Value) 4 End Sub