|
- Sub s()
- Dim rg As Range, x, brr()
- Dim d As New Dictionary
- Dim change As Boolean
- arr = Sheets(1).Range("a2:a" & Cells(Rows.Count, 1).End(3).Row)
- ReDim Preserve brr(1 To UBound(arr))
- For i = 1 To UBound(arr)
- change = False
- If Not d.Exists(arr(i, 1)) Then change = True
- If i > 1 Then
- If arr(i, 1) <> arr(i - 1, 1) Then change = True
- End If
-
- If change Then
- d(arr(i, 1)) = ""
- brr(i) = 1
- n = 1
- Else
- n = n + 1
- brr(i) = n
- End If
- Next i
- Sheets(1).Range("b2").Resize(UBound(brr)) = Application.Transpose(brr)
- End Sub
复制代码 |
|