LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default 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
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
identifying multi-select items in a listbox JT Excel Programming 1 January 7th 08 09:14 PM
Multi-Select List Box [email protected] Excel Programming 4 October 25th 07 10:47 AM
Hi-lighting items in a multi-select List box Dan Excel Programming 6 June 4th 07 10:44 PM
Putting items from list box multi-select onto worksheet ericd Excel Programming 0 February 26th 04 08:16 PM
Extract values from a multi-select multi-column list-box Peter[_20_] Excel Programming 5 September 28th 03 04:04 PM


All times are GMT +1. The time now is 09:52 PM.

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"