ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Link two listboxes together (https://www.excelbanter.com/excel-programming/347361-link-two-listboxes-together.html)

greenfalcon[_8_]

Link two listboxes together
 

I have a quick question. I have a form with lets say 2 separet
listboxes on it. A lstBox1 and lstBox2. Now what i need these to do i
if you scroll down with list box1, listbox2 moves scrolls down as well
Really what i am trying to do is the two listboxes have data in the
that needs to relate to the information in the other one, I cant hav
one list box move because then all the data is in the wrong place...
for example

This is how its supposed to look

lstBox1 lstBox2
a a
b b
c c
d d

i cant have this happen, when scroll box1 is scrolled the info in box
does not move.

lstBox1 lstBox2

b a
c b
d c


Hopefully this is clear enough.

Thanks for your hel

--
greenfalco
-----------------------------------------------------------------------
greenfalcon's Profile: http://www.excelforum.com/member.php...fo&userid=1362
View this thread: http://www.excelforum.com/showthread.php?threadid=49082


greenfalcon[_9_]

Link two listboxes together
 

i wonder if this is even possible


--
greenfalcon
------------------------------------------------------------------------
greenfalcon's Profile: http://www.excelforum.com/member.php...o&userid=13622
View this thread: http://www.excelforum.com/showthread...hreadid=490823


Dave Peterson

Link two listboxes together
 
I don't know if it's possible, but why not just have multiple columns in one
listbox and make the listbox wide enough to show both. It seems like a much
easier solution.

But you could sync the listboxes after you leave one of them:

Option Explicit
Private Sub ListBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.ListBox1.TopIndex = Me.ListBox2.TopIndex
End Sub
Private Sub ListBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.ListBox2.TopIndex = Me.ListBox1.TopIndex
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.ListBox1
.IntegralHeight = True
For iCtr = 1 To 20
.AddItem "asdf" & iCtr
Next iCtr
End With
With Me.ListBox2
.IntegralHeight = True
.Top = Me.ListBox1.Top
.Height = Me.ListBox1.Height
For iCtr = 1 To 20
.AddItem "qwer" & iCtr
Next iCtr
End With
End Sub

greenfalcon wrote:

i wonder if this is even possible

--
greenfalcon
------------------------------------------------------------------------
greenfalcon's Profile: http://www.excelforum.com/member.php...o&userid=13622
View this thread: http://www.excelforum.com/showthread...hreadid=490823


--

Dave Peterson


All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com