Option Explicit
Sub test()
Dim i, j, n, t, arr, m
arr = Sheets("sheet1").UsedRange.Value
ReDim brr(1 To UBound(arr, 1) * UBound(arr, 2), 1 To 1) As String
For j = 1 To 5 Step 2
For i = 1 To UBound(arr, 1)
If Len(arr(i, j)) > 0 Then
n = n + 1: brr(n, 1) = arr(i, j)
End If
Next i, j
For i = 1 To n - 1
For j = i + 1 To n
If Val(brr(i, 1)) > Val(brr(j, 1)) Then
t = brr(i, 1): brr(i, 1) = brr(j, 1): brr(j, 1) = t
End If
Next j, i
For i = 1 To n
For j = i To n
If brr(j, 1) <> brr(j + 1, 1) Then
m = m + 1: brr(m, 1) = brr(i, 1)
i = j: Exit For
End If
Next j, i
With [g:g]
.ClearContents
.Resize(m) = brr
End With
End Sub |