Hi everyone. I encounter a problem regarding the coding of a function which is designed to sort the (n by 3) matrix by largest value e.g
transform
CHF EUR 0.923126
CHF USD 0.154571
EUR USD 0.254522
into
CHF EUR 0.923126
EUR USD 0.254522
CHF USD 0.154571
here is my coding:
Code
Function Sorting(vector1 As Variant)
Dim n, k, i, j 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
temp(k, 1) = vector1(j, 1)
temp(k, 2) = vector1(j, 2)
temp(k, 3) = vector1(j, 3)
Next j
Sorting = temp
End Function
Display More
I dont know where went wrong, i m an beginner, please help!!!!!