Sync scroll of two ListBoxes

  • Thread starter Thread starter count
  • Start date Start date
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
 
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
 
Back
Top