-
[VBA]Function Sorting(vector1 As Variant)
Dim n, k, i, j, m As Integer
Dim temp As Variant
n = vector1.Rows.Count
ReDim temp(1 To n, 1 To 3)
For j = 1 To n
k = n
For i = 1 To n
If (Abs(vector1(j, 3))) > (Abs(vector1(i, 3))) Then
k = k - 1
End If
Next i
'test for prior equal value; if found; enter above
For m = 1 To n
If vector1(j, 3) = temp(m, 3) Then
k = m - 1
Exit For
End If
Next
temp(k, 1) = vector1(j, 1)
temp(k, 2) = vector1(j, 2)
temp(k, 3) = vector1(j, 3)
Next j
Sorting = temp
End Function[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules