Article ID: 165632
Article Last Modified on 11/23/2006
A1: Alpha
A2: Bravo
A3: Charlie
A4: Delta
A5: Echo
Sheet1!A1:A5
Private Sub CommandButton1_Click()
ListBox1.RowSource = ""
End Sub
Private Sub UserForm_Initialize()
Dim MyArray As Variant
Dim i As Integer
'Initialize array with values to populate ListBox.
MyArray = Array("Alpha", "Bravo", "Charlie", "Delta", "Echo")
For i = LBound(MyArray) To Ubound(MyArray)
'Add a value from MyArray to ListBox1.
UserForm1.ListBox1.AddItem MyArray(i)
Next
End Sub
This procedure populates ListBox1 when the UserForm is loaded.
Private Sub CommandButton1_Click()
Dim i As Integer
For i = 1 To ListBox1.ListCount
'Remove an item from the ListBox.
ListBox1.RemoveItem 0
Next i
End Sub
This Visual Basic procedure removes all of the items from ListBox1.
120802 Office: How to Add/Remove a Single Office Program or Component
Additional query words: XL97 user form
Keywords: kbhowto kbprogramming kbui KB165632