ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sync scroll of two ListBoxes (https://www.excelbanter.com/excel-programming/299274-sync-scroll-two-listboxes.html)

count

Sync scroll of two ListBoxes
 
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



Vic Eldridge

Sync scroll of two ListBoxes
 
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
----------------------------------




"count" wrote in message ...
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



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

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