Sub apparigliamento()
'
Dim i As Integer, j As Integer, FineCol1 As Integer, FineCol2 As Integer
Cells(1, 1).Select
Selection.End(xlDown).Select
FineCol1 = Selection.Row
Cells(1, 2).Select
Selection.End(xlDown).Select
FineCol2 = Selection.Row
i = 1
j = 1
Do Until Cells(i, 1).Text = "" Or Cells(j, 2).Text = ""
Select Case True
Case Cells(i, 1).Value < Cells(j, 2).Value
Call scala(j, 2, FineCol1)
FineCol1 = FineCol1 + 1
Case Cells(i, 1).Value > Cells(j, 2).Value
Call scala(i, 1, FineCol2)
FineCol2 = FineCol2 + 1
End Select
i = i + 1
j = j + 1
Loop
End Sub
Sub scala(indrig As Integer, indcol As Integer, FineCol As Integer)
For indi = FineCol To indrig Step -1
Cells(indi + 1, indcol) = Cells(indi, indcol).Text
Next
Cells(indrig, indcol) = ""
End Sub |