Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Pre-Select items in Multi-Select List on Form
Hi,
I have a worksheet that has 2 lists... buildList is a "master" list containing all possibilities for a field (like validation). currentList is active subset of the "master" list. Instead of modifying currentList manually, I want a form to pop up that shows a list of all the possibilies (buildList), but also pre-selects all the items in the currentList. My code below adds all the items properly, but I can't figure out how to pre-select items. I think the problem lies with this line of code: TheList1.List(i - 1).Selected = True This should get executed if the item currently being added to the list from the master list is contained in the "currentlist". It's possible that the index isn't right but am not sure. Thanks, MikeZz Private Sub UserForm_Initialize() Dim i, c, r, r1, c1 Dim AddThis Dim defR, defC Dim It errToMany = False TheList1.Clear tempCurr = currentList defR = UBound(currentList, 1) - LBound(currentList, 1) + 1 defC = UBound(currentList, 2) - LBound(currentList, 2) + 1 For i = LBound(buildList, 1) To UBound(buildList, 1) AddThis = True If (listType = "Company" And buildList(i) = CompanyName) Or _ buildList(i) = "Other" Or buildList(i) = "OT" Then AddThis = False End If If AddThis = True Then TheList1.AddItem buildList(i): c = TheList1.ListCount For r1 = 1 To defR For c1 = 1 To defC ' It = TheList1.List(TheList1.ListCount) If currentList(r1, c1) = buildList(i) Then ' TheList1.List(i - 1).Selected = True GoTo gotonextItem End If Next c1 Next r1 gotonextItem: End If Next i TheList1.AddItem "Other" Qty.Caption = 0 Qty2.Caption = TheList1.ListCount FormTitle.Caption = "Primary Co: " & CompanyName FormTitle.Visible = True End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
identifying multi-select items in a listbox | Excel Programming | |||
Multi-Select List Box | Excel Programming | |||
Hi-lighting items in a multi-select List box | Excel Programming | |||
Putting items from list box multi-select onto worksheet | Excel Programming | |||
Extract values from a multi-select multi-column list-box | Excel Programming |