Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to drag items within listbox MP Excel Discussion (Misc queries) 0 January 15th 09 03:56 PM
Adding items to columns in a listbox Daniel Bonallack Excel Discussion (Misc queries) 1 May 7th 07 04:45 PM
filtering to show items in a listbox eileenj Excel Discussion (Misc queries) 1 August 11th 06 01:30 PM
Deleting Duplicate items in a ListBox CLamar Excel Discussion (Misc queries) 24 June 13th 06 06:22 PM
Problem using INDEX to select items in listbox Shazbot Excel Discussion (Misc queries) 3 April 28th 06 09:06 AM


All times are GMT +1. The time now is 08:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"