Oi,
outro aluno pediu para eu resolver o exercício de colocar uma lista de números em ordem crescente. Esse exercício é um pouquinho mais complicado, recomendo a todos tentarem fazer antes de olhar a resposta. Se não conseguirem de jeito nenhum, olhem a resposta abaixo e vejam se a entendem.
Sub MenorValor(Ini As Integer, Fim As Integer)
Dim Menor As Integer
Dim LinhaMenor As Integer
Dim i As Integer
i = Ini
Do While (Cells(i, 4) = "x")
i = i + 1
Loop
Menor = Cells(i, 1)
LinhaMenor = i
Do While (i <= Fim)
If ((Cells(i, 1) <= Menor) And (Cells(i, 4) <> "x")) Then
Menor = Cells(i, 1)
LinhaMenor = i
End If
i = i + 1
Loop
Cells(2, 3) = Menor
Cells(LinhaMenor, 4) = "x"
End Sub
Sub Ordem()
Dim Quant As Integer
Dim i As Integer
Quant = Cells(1, 3)
i = 1
Do While (i <= Quant)
Cells(i, 4) = ""
i = i + 1
Loop
i = 1
Do While (i <= Quant)
Call MenorValor(1, Quant)
Cells(i, 2) = Cells(2, 3)
i = i + 1
Loop
End Sub