
Option Explicit
Sub abc()
Dim a, i, j, m, p
a = Range("a2:c" & [a2].End(xlDown).Row + 1).Value
Call bsort(a, 1, UBound(a) - 1, 1, UBound(a, 2), 1)
For i = 1 To UBound(a) - 1
If a(i, 1) <> a(i + 1, 1) Then
Call bsort(a, p + 1, i, 1, UBound(a, 2), 3)
m = m + 1
For j = 1 To UBound(a, 2)
a(m, j) = a(p + 1, j)
Next
p = i
End If
Next
[a2].Offset(, UBound(a, 2) + 1).Resize(m, UBound(a, 2)) = a
End Sub
Function bsort(a, first, last, left, right, key)
Dim i, j, k, t
For i = first To last - 1
For j = first To last + first - 1 - i
If a(j, key) > a(j + 1, key) Then
For k = left To right
t = a(j, k): a(j, k) = a(j + 1, k): a(j + 1, k) = t
Next
End If
Next
Next
End Function