im trying to sorting the data into ascending order then calculate the median. but im having trouble when sorting it into ascending order. can you look at my code :
Dim x As Integer, j As Integer, t As Integer
Dim median As Single
Dim num(0 To 100) As Integer
Dim order(0 To 100) As Integer
Dim count As Integer
row = 3
Do
num(t) = Val(Sheet1.Cells(row + t, 2))
t = t + 1
count = count + 1
Loop While Sheet1.Cells(row + t, 2) <> ""
For j = 0 To count
For t = j To count
If num(j) < num(t) Then
order(j) = num(t)
Else
order(j) = num(t + 1)
End If
Next t
Next j
row = 12
For t = 0 To count
Sheet1.Cells(row + t, 2) = order(t)
Next t
so the problem is at the for t = j to count, the if else is wrong and i dont know how to fix it already.can someone please help me
Dim x As Integer, j As Integer, t As Integer
Dim median As Single
Dim num(0 To 100) As Integer
Dim order(0 To 100) As Integer
Dim count As Integer
row = 3
Do
num(t) = Val(Sheet1.Cells(row + t, 2))
t = t + 1
count = count + 1
Loop While Sheet1.Cells(row + t, 2) <> ""
For j = 0 To count
For t = j To count
If num(j) < num(t) Then
order(j) = num(t)
Else
order(j) = num(t + 1)
End If
Next t
Next j
row = 12
For t = 0 To count
Sheet1.Cells(row + t, 2) = order(t)
Next t
so the problem is at the for t = j to count, the if else is wrong and i dont know how to fix it already.can someone please help me