Sub ABC()
Dim sArr(), Arr() As Long, Res()
Dim i&, iR&, n&, j&, jC&, sCol&, sRow&, tmp
On Error Resume Next
sArr = Range("G2:M9").Value
sRow = UBound(sArr, 1): sCol = UBound(sArr, 2)
ReDim Arr(0 To 9, 0 To 9)
For i = 1 To sRow
For j = 1 To sCol
tmp = sArr(i, j)
If tmp <> Empty Then
iR = tmp Mod 10: jC = tmp \ 10
Arr(iR, jC) = Arr(iR, jC) + 1
End If
Next j
Next i
ReDim Res(1 To 200, 0 To 9) 'Max 200 dong ket qua
sRow = 0
For j = 0 To 9
k = 0
For i = 0 To 9
For n = 1 To Arr(i, j)
k = k + 1
Res(k, j) = i + j * 10
Next n
Next i
If k > sRow Then sRow = k
Next j
Range("B13:K212").ClearContents
Range("B13").Resize(sRow, 10) = Res
End Sub