Friday, August 26, 2011

Sorted List By Array Function :

If you want to Sort Your List By Function , You can use this Array Function ,



Option Base 1
Option Compare Text
Function SortedList(rng As Range) As Variant
        Dim arr() As Variant
        Dim rw, cl As Double
        r = rng.Rows.Count
        cl = 1
        ReDim arr(r, cl)
                arr = rng
                For i = 1 To r
                    For j = 1 To r - i
                        If arr(j, 1) > arr(j + 1, 1) Then
                            temp = arr(j, 1)
                                arr(j, 1) = arr(j + 1, 1)
                                arr(j + 1, 1) = temp
                            End If
                    Next
                Next
            SortedList = arr
End Function

No comments: