ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I link multiple Listboxes to one Scrollbar (https://www.excelbanter.com/excel-programming/387455-can-i-link-multiple-listboxes-one-scrollbar.html)

[email protected]

Can I link multiple Listboxes to one Scrollbar
 
Hi,

Is there a way to control multiple listboxes via just one forms
Scrollbar? The number of rows in all the listboxes is the same.

I appreciate all your help
Thanks


Incidental

Can I link multiple Listboxes to one Scrollbar
 
Hi

I am not sure exactly what your after but i added three listboxes and
a scroll bar to a userform and then ran the following code, not the
nicest looking code but it should work

Option Explicit
Dim i As Integer

Private Sub ScrollBar1_Change()
i = ScrollBar1.Value 'pass the scroll bar value to an integer and then
ListBox1.ListIndex = i 'pass that integer to each listbox.listindex
value
ListBox2.ListIndex = i
ListBox3.ListIndex = i
End Sub

Private Sub UserForm_Initialize()
ListBox1.RowSource = "a1:a27" ' these just setting a ref for the test
ListBox2.RowSource = "b1:b27"
ListBox3.RowSource = "c1:c27"
ScrollBar1.Min = 0 'set the min as 0 due to listindex defaulting from
0 up
ScrollBar1.Max = 26 'as above set the last number for your scrollbar
keeping
'in mind that you are starting from 0
End Sub

hope this is of some use to you

S



All times are GMT +1. The time now is 12:23 PM.

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