张雄友 发表于 2013-6-7 20:12
无法实现。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ar, i%, d As Object
Application.EnableEvents = False
If Target.Column = 1 Then
Set d = CreateObject("scripting.dictionary")
[b2].Resize(Cells(Rows.Count, 1).End(3).Row - 1, 2).ClearContents
ar = Range("a2:C" & Cells(Rows.Count, 1).End(3).Row)
For i = 1 To UBound(ar)
If Not d.exists(ar(i, 1)) Then ar(i, 2) = ar(i, 1)
d(ar(i, 1)) = d(ar(i, 1)) + 1
ar(i, 3) = d(ar(i, 1))
Next
[a2].Resize(UBound(ar), 3) = ar
Set d = Nothing
End If
Application.EnableEvents = True
End Sub