View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Andy Pope Andy Pope is offline
external usenet poster
 
Posts: 2,489
Default on Listbox in Userform....

Hi,

Try this.
'-----------------------------
Private Sub CommandButton1_Click()

If ListBox1.ListIndex 0 Then
ListBox1.ListIndex = ListBox1.ListIndex - 1
End If

End Sub

Private Sub CommandButton2_Click()

If ListBox1.ListIndex < ListBox1.ListCount - 1 Then
ListBox1.ListIndex = ListBox1.ListIndex + 1
End If

End Sub

Private Sub UserForm_Initialize()

ListBox1.List = Array(1, 2, 3, 4, 5, 6)
CommandButton1.Caption = "Up"
CommandButton2.Caption = "Down"

End Sub
'-----------------------------

Cheers
Andy

x taol wrote:
hello.

The userform have two buttons and one listbox.

i want to move up or down a item of listbox.
first, select the item of listbox and if press a button(up) of two
button, the item move up one step....

but vba code, i don't know that.


*** Sent via Developersdex http://www.developersdex.com ***


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info