Sub test()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
For i = 1 To Cells(Rows.Count, 1).End(3).Row
d(Cells(i, 1).Value) = d(Cells(i, 1).Value) + 1
If Cells(i, 1) <> Cells(i + 1, 1) Then
ary = d.items
Cells(i, 2) = ary(0)
d.RemoveAll
End If
Next
End Sub
求个完整的函数或宏