View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Sorting of values within a list box

You can run this code on the move

Dim i As Long
Dim j As Long
Dim tmp

With Me.ListBox1
For i = 1 To .ListCount - 1
For j = i + 1 To .ListCount - 1
If .List(i) .List(j) Then
tmp = .List(i)
.List(i) = .List(j)
.List(j) = tmp
End If
Next j
Next i
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Zippy " wrote in message
...
I am building a reporting tool containing a form with two list boxes,
these list boxes essesentially signify include or exclude. The user
moves numeric values between these list boxes to choose what questions
will be displayed in graphs in later steps.

What the user moves from one box to another can mean that the contents
of the list box fall out of numerical order and this can be confusing
for the user (So I'm told). Is there a way to sort the values within a
list box, probably when an item is added or removed so that they
maintain chronological order.


---
Message posted from http://www.ExcelForum.com/