Sorry, yes alphabetically sorted.
Many thanks
B
> Sorry, yes alphabetically sorted.
Hi Ben,
OK, the simplest thing is to do the following.
1. Extract the contents of the listbox into a Variant that contains an
array, something like this
Dim vArray as Variant
vArray = ListBox1.List
vArray now contains a 2-dimensional array containing all the elements of the
listbox. If the listbox has only one column, you access each element in the
form vArray(n, 0) to get at the nth element (counting from zero)
2. Sort the array. There are plenty of routines on the web for sorting. If
you plug the words VB and Quicksort into a Google search, you will come
across plenty of them. The code may have to be modified to allow for the
fact that you are sorting a 2-d array even though it has only one column.
You can write your own sort routine if you want to, but the Quicksort code
samples that are available on the web are usually the fastest.
3. Put the sorted array back into the listbox. This is easily done
ListBox1.List = vArray

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org