Sync scroll of two ListBoxes

C

count

Hi,
I use two adjoining ListBoxes and need to have them kept in sync. All works
as long as there's no vertical scrollbar involved - I use:
sub ListBox1_Click (etc)
ListBox2.ListIndex = ListBox1.ListIndex
end sub

What Event or technique would move the highlighted row in ListBox2 in sync
with ListBox1, when scrolling occurs on the latter?
TIA
Paul
 
V

Vic Eldridge

Hi Paul,

Try placing the following code into the code module of the worksheet that
contains your listboxes.

Regards,
Vic Eldridge

----------------------------------
Dim Synchronised As Boolean

Private Sub Worksheet_Activate()
Synchronised = True
Looper
End Sub

Private Sub Worksheet_Deactivate()
Synchronised = False
End Sub

Sub Looper()
Do While Synchronised = True
ListBox2.ListIndex = ListBox1.ListIndex
ListBox2.TopIndex = ListBox1.TopIndex
DoEvents
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top