In VBA:
Code:
Sub M_snb()
sn = Range("D1:G24")
sp = Array(116, 128, 140, 152, 164, 176, "S", "XS")
With CreateObject("scripting.dictionary")
.Item(" ") = sp
For j = 2 To UBound(sn)
For jj = 1 To UBound(sn, 2)
If sn(j, jj) <> "" Then
ReDim st(7)
If .exists(sn(1, jj)) Then st = .Item(sn(1, jj))
y = Application.Match(sn(j, jj), sp, 0) - 1
st(y) = st(y) + 1
.Item(sn(1, jj)) = st
End If
Next
Next
Sheet1.Cells(40, 1).Resize(.Count) = Application.Transpose(.keys)
Sheet1.Cells(40, 2).Resize(.Count, 8) = Application.Index(.items, 0, 0)
End With
End Sub