Reorder items in listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to reorder items in a listbox. Possibilities include sorting
the items or dragging and dropping an item to its nes position.

The data is not bound to cells in a sheet.

Thanks.
 
Dim v as Variant, i as long, j as Long
Dim swap as String
v = Userform1.Listbox1.List
For i = lbound(v) to ubound(v)-1
For j = i + 1 To ubound(v)
If v(i) > v(j) Then
Swap = v(i)
v(i) = v(j)
v(j) = Swap
End If
Next j
Next i

Useform1.Listbox1.List = v
 
Back
Top