Listbox--moving items up or down

  • Thread starter Thread starter KimberlyC
  • Start date Start date
K

KimberlyC

Hi

I have a user form that has a listbox in it.
The listbox is populated from a row of data on a worksheet using the
following code that this news group gave me:
Private Sub UserForm_Initialize()
Dim x As Long

For x = 3 To 13
listbox1.AddItem (Sheets("Worksheet ").Cells(9, x))
Next

It works great!
I would like to be able to allow the user to move the items up or down and
put them in the order of their choice.
Once it's in the order of their choice, they then select the items they
want, and those items are copied to another worksheet using this code:
Dim i As Integer
Dim j As Integer

With listbox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Range("codestosummary").Offset(j, 0).Value = .List(i)
j = j + 1
End If
Next i
End With

I'm having trouble with the part of allowing the user to move the items up
or down to get them in the order they prefer.
I'm sure how this would be done!!
Any help with this would be greatly appreciated.
Thanks in advance.
Kimberly
 
Hi

I don't know how to allow a user to move values in list
box, but you could have a 2nd listbox which can be
populated from the first listbox by the user, in whatever
order they want? The values in the 2nd listbox could then
be copied to the sheet.

libby
 
Back
Top