Option Explicit
Function Uname(cell As Range)
Dim i&, Ln As Range, st, ce As Range, max&
Set Ln = Range("C1:C" & cell.Row - 1)
st = Split(" " & cell.Value)
For i = 1 To UBound(st) - 1
Uname = Uname & LCase(Left(st(i), 1))' LCase: Họ và Lót viết thường. Nếu muốn viết hoa thì dùng Ucase
Next
Uname = st(UBound(st)) & Uname
If WorksheetFunction.CountIf(Ln, Uname & "*") = 0 Then Exit Function
For Each ce In Ln
st = Replace(ce, Uname, "")
If Len(st) = 0 Then
max = 1
ElseIf IsNumeric(st) Then max = max + 1
End If
Next
Uname = Uname & IIf(max = 0, "", max)
End Function