Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking Listbox Items
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to drag items within listbox | Excel Discussion (Misc queries) | |||
Adding items to columns in a listbox | Excel Discussion (Misc queries) | |||
filtering to show items in a listbox | Excel Discussion (Misc queries) | |||
Deleting Duplicate items in a ListBox | Excel Discussion (Misc queries) | |||
Problem using INDEX to select items in listbox | Excel Discussion (Misc queries) |