View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Checking Listbox Items

this worked for me:

Private Sub CommandButton1_Click()
Dim i As Long
With Worksheets("Sheet2")
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
.Range("A1")(i + 1, 2).Value = _
.Range("A1")(i + 1, 1).Value
Else
.Range("A1")(i + 1, 2).ClearContents
End If
Next
End With
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim itm As Range
Dim i As Long
With Worksheets("Sheet2")
i = 0
For Each itm In .Range("A1:A14")
ListBox1.AddItem itm.Value
If Not IsEmpty(itm.Offset(0, 1)) Then
ListBox1.Selected(i) = True
End If
i = i + 1
Next
End With
End Sub


Regards,
Tom Ogilvy


Tim wrote in message
...
Hi, All.

I have a wizard that includes a listbox. When the wizard is initialized,
the entries in cells A1:A14 populate the listbox using the .AddItem

method.
The listbox has the ListStyle property set to 1-fmListStype Option and the
MultiSelect property as 1-fmMultiSelectMulti. When the user selects a
number of the items in the list, the selected items populate a range that

is
B1:B14 (or less, depending on the number of items selected). What I am
having trouble doing is placing checkmarks next to the [previously

selected]
item the second, and subsequent, time the wizard runs. Any help would be
greatly appreciated.