I have a column with these numbers
421
102
883
973
487
620
146
218
I would like to sort them from high to low (in terms of left to right) Ex...
124
012
388
379
478...etc
I have a column with these numbers
421
102
883
973
487
620
146
218
I would like to sort them from high to low (in terms of left to right) Ex...
124
012
388
379
478...etc
Last edited by Jordans121; 08-07-2013 at 05:12 PM.
Are they all 3 characters long?
Please click the * icon below if I have helped.
Yes. All numbers are 3 characters long and are located in column B (from row 2:1001).
Is this is what you are after?
![]()
Public Function ArraySort(ByVal vValue As Variant) As String Dim strv As String, strtemp As String, strFinal As String Dim i As Integer, x As Integer, y As Integer Dim strArray As Variant strv = vValue For i = 1 To Len(strv) strtemp = strtemp & "," & Mid(strv, i, 1) Next i strtemp = Right(strtemp, Len(strtemp) - 1) strArray = Split(strtemp, ",") For x = LBound(strArray) To (UBound(strArray) - 1) For y = (x + 1) To UBound(strArray) If strArray(x) > strArray(y) Then strtemp = strArray(x) strArray(x) = strArray(y) strArray(y) = strtemp strtemp = "" End If Next y Next x For i = LBound(strArray) To UBound(strArray) strFinal = strFinal & strArray(i) Next i ArraySort = strFinal End Function
Yes. Thanks
Last edited by Jordans121; 08-07-2013 at 05:11 PM.
ArraySort is an User-Defined Function. Just copy the code to your workbook.
If they wont sort as numbers, that means they are text, looking like numbers, and should sort as such, when you sort them.
If this is not happening, can you upload a sample workbook, showing what you are working with?
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks