Can I link multiple Listboxes to one Scrollbar

R

rachitm

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
 
I

Incidental

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
 

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