|
-
Feb 11th, 2012, 09:50 AM
#1
Thread Starter
New Member
Linking 2 listboxes? <PLEASE HELP!>
Hi. New to the forum. Hopefully someone can help me out here. I'm using Excel and have a userform that has a series of listboxes. What I want is for the user to be able to select a value in one listbox and then have the corresponding values from the other listboxes selected as a result. What I'm trying to do is capture the listbox1.listindex from the one and then store it as variable "workindex". Then I use workindex to select the values in the other listboxes using ListBox2.Selected(workindex). Here is the actual code where I've inserted message boxes to display the results.
HTML Code:
Private Sub ListBox1_Click()
Dim work, quote, CETTab, ID, workcount, workindex As Variant
Dim X, Y, z As Variant
work = ListBox1.Value
workindex = ListBox1.ListIndex
MsgBox workindex
ListBox2.Selected(workindex) = True '
MsgBox ListBox2.Value
ID = ListBox2.Value
MsgBox ID
End Sub
the messagebox for workindex always displays the correct number. The first time I ran this routine, the other messageboxes displayed the right info. Then after that, they no longer worked and always came up blank. Any help would be appreciated.
Please Help!
-
Feb 11th, 2012, 10:54 AM
#2
Frenzied Member
Re: Linking 2 listboxes? <PLEASE HELP!>
you want to set the listbox2.selected(indexed value) to true
you mean listbox2.selected(listbox1.listindex)=true
is that correct?
-
Feb 11th, 2012, 11:16 AM
#3
Thread Starter
New Member
Re: Linking 2 listboxes? <PLEASE HELP!>
Thanks for the reply "Incidentals"
I tried changing the code as you suggested...
Instead of...
ListBox2.Selected(workindex) = True
I put
ListBox2.Selected(Listbox1.listindex) = True
The same as with the code that I was using, it appears to highlight the appropriate value in listbox2. But, my msgbox listbox2.value still shows up as blank. So, I'm still not getting the output from listbox2 that I can store as a variable for use later.
Thoughts? I tried uploading my test excel file to this post, but I keep getting invalid file type.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|