i have 4 Column list box i tryed to Move the selected item up one position but only first Column worked.Please Help Any One
Sub MoveUp()
'PURPOSE: Move the selected item up one position in the list
Dim x As Long
Dim Count As Long
Dim Position As Long
'Is there an item selected?
If ListBox1.ListIndex = -1 Then Exit Sub
'Which Item is selected?
For x = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(x) = True Then
Position = x
Count = Count + 1
If Count > 1 Then Exit Sub 'More than 1 item selected
End If
Next x
'Selected item already at the top?
If Position = 0 Then Exit Sub
'Add an item above the current selection
ListBox1.AddItem ListBox1.List(Position), Position - 1
'Remove Original Selection
ListBox1.RemoveItem Position + 1
'Re-select the item that got moved
ListBox1.Selected(Position - 1) = True
End Sub
Sub MoveUp()
'PURPOSE: Move the selected item up one position in the list
Dim x As Long
Dim Count As Long
Dim Position As Long
'Is there an item selected?
If ListBox1.ListIndex = -1 Then Exit Sub
'Which Item is selected?
For x = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(x) = True Then
Position = x
Count = Count + 1
If Count > 1 Then Exit Sub 'More than 1 item selected
End If
Next x
'Selected item already at the top?
If Position = 0 Then Exit Sub
'Add an item above the current selection
ListBox1.AddItem ListBox1.List(Position), Position - 1
'Remove Original Selection
ListBox1.RemoveItem Position + 1
'Re-select the item that got moved
ListBox1.Selected(Position - 1) = True
End Sub