ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   spin up / spin down (https://www.excelbanter.com/excel-programming/395248-spin-up-spin-down.html)

JT

spin up / spin down
 
I have 2 listboxes (LB1 and LB2) side by side on a form. There are over 300
items in each list box. Each list box has been loaded. Now I would like to
use a spin button to move up and down through each list box. Any help on
getting started with the code to move up and down through the list boxes
would be GREATLY appreciated. Thanks for all of the help........

FYI...there are 6 columns of various length in each list box. Does this
make a difference? I'm considering combining my data for each row into a
single column. Do I need to do that to use a spin button?
--
JT

Tom Ogilvy

spin up / spin down
 
Private Sub SpinButton1_SpinDown()
With ListBox1
If .ListIndex < .ListCount - 1 Then
.ListIndex = .ListIndex + 1
End If
End With
End Sub

Private Sub SpinButton1_SpinUp()
With ListBox1
If .ListIndex 0 Then
.ListIndex = .ListIndex - 1
End If
End With
End Sub

worked for me. Adjust it to handle two listboxes.

--
Regards,
Tom Ogilvy


"JT" wrote:

I have 2 listboxes (LB1 and LB2) side by side on a form. There are over 300
items in each list box. Each list box has been loaded. Now I would like to
use a spin button to move up and down through each list box. Any help on
getting started with the code to move up and down through the list boxes
would be GREATLY appreciated. Thanks for all of the help........

FYI...there are 6 columns of various length in each list box. Does this
make a difference? I'm considering combining my data for each row into a
single column. Do I need to do that to use a spin button?
--
JT


JT

spin up / spin down
 
Thank You very much.......It is working exactly like I want it to.

One more question.......is it possible to highlight the first row in each
listbox when the form opens and then move the highlighted row either up or
down with the spin button?

Thanks again for all of the help..
--
JT


"Tom Ogilvy" wrote:

Private Sub SpinButton1_SpinDown()
With ListBox1
If .ListIndex < .ListCount - 1 Then
.ListIndex = .ListIndex + 1
End If
End With
End Sub

Private Sub SpinButton1_SpinUp()
With ListBox1
If .ListIndex 0 Then
.ListIndex = .ListIndex - 1
End If
End With
End Sub

worked for me. Adjust it to handle two listboxes.

--
Regards,
Tom Ogilvy


"JT" wrote:

I have 2 listboxes (LB1 and LB2) side by side on a form. There are over 300
items in each list box. Each list box has been loaded. Now I would like to
use a spin button to move up and down through each list box. Any help on
getting started with the code to move up and down through the list boxes
would be GREATLY appreciated. Thanks for all of the help........

FYI...there are 6 columns of various length in each list box. Does this
make a difference? I'm considering combining my data for each row into a
single column. Do I need to do that to use a spin button?
--
JT



All times are GMT +1. The time now is 08:29 AM.

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