Rảnh rỗi nên code cái này. Mong sẽ có ích đối với bạn
Sub mahang()
Dim nhom(), mahang()
Dim lr As Long
Dim i As Long
lr = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
nhom = Sheet1.Range("A2:A" & lr).Value
ReDim mahang(1 To UBound(nhom), 1 To 1)
For i = 1 To UBound(nhom)
mahang(i, 1) = nhom(i, 1) & "." & WorksheetFunction.CountIf(Range("A1:A" & i), nhom(i, 1)) + 1
Next
Sheet1.Range("B2:B" & lr).ClearContents
Sheet1.Range("B2:B" & lr).NumberFormat = "@"
Sheet1.Range("B2").Resize(UBound(nhom)).Value = mahang
End Sub