PDA

View Full Version : scroll to an item on a list box



philfer
03-02-2011, 11:31 AM
Hello,

I am using two listboxes the first fills with column headings and you can press a button with > on it to move it to the second list box

Multiselect is set to None

If I select an item in the fist listbox quite far down (there is a vertical scroll bar) I get get it to select the next item by using :-

.Select(whatever)=True

but it doesnt show the item in the listbox but instead is back at the top

Is there a way both to select the item and also show it in the listbox

I have played around with .selected and .listindex to no avail

Any help

Thanks
Phil

Bob Phillips
03-02-2011, 11:36 AM
Can you post the workbook?

Kenneth Hobs
03-02-2011, 11:54 AM
Private Sub CommandButton1_Click()
If ListBox1.ListIndex <> ListBox1.ListCount - 1 Then _
ListBox1.ListIndex = ListBox1.ListIndex + 1
End Sub

Private Sub UserForm_Initialize()
Dim i As Integer
For i = 1 To 100
ListBox1.AddItem i, i - 1
Next i
End Sub

philfer
03-02-2011, 12:05 PM
Hello,

Ignore this post, sorry, it seems to work ok in Excel. Now I am migrating it to Access where it doesnt work!!!!

As if my life wasnt complicated enough!

Cheers guys