Could anyone show me how to sort a list box alphabetically?
Thanks.
Could anyone show me how to sort a list box alphabetically?
Thanks.
How are you storing the data for the row source? (This was my 100th post! Yay!)
I read the data from the column in excel worksheets "Sheet1" column "C".
How do I also to read the string value from the listbox with multiple selection?
For example, MsgBox() for every value that is selected.
Thanks.
This is the solution that I used. Hope it can help everyone.
Thanks.Function SortListBoxArray(ByRef vTemp As Variant) Dim vArr(), vSArr() As String, vItm As Variant, i As Long vArr = vTemp.List i = 0 For Each vItm In vArr ReDim Preserve vSArr(i) vSArr(i) = vItm i = i + 1 Next vItm SortStringArray vSArr vTemp.List = vSArr End Function Sub SortStringArray(x) ' Function: sorts virtually any data type from smallest to largest ' Limitations: assumes entire array from LBound(X) to UBound(X) is to be sorted ' Passed Values: X [in, any] array of values Dim i As Long Dim J As Long Dim temp Dim PerDone As Double For i = LBound(x) To UBound(x) - 1 For J = i + 1 To UBound(x) If x(i) > x(J) Then temp = x(i) x(i) = x(J) x(J) = temp End If Next J Next i End Sub