|
- Sub 重复添加序号()
- Dim Arr, i, j, Dic As Object, k&
- Set Dic = CreateObject("Scripting.Dictionary")
- j = 8'处理的列号,自己更改。
- Arr = Range(Cells(1, j), Cells(Rows.Count, j).End(xlUp))
- For i = 2 To UBound(Arr)
- If Arr(i, 1) <> "" Then
- If Not Dic.Exists(Arr(i, 1)) Then
- Dic(Arr(i, 1)) = -i
- Else
- If Dic(Arr(i, 1)) < 0 Then
- k = -Dic(Arr(i, 1)): Arr(k, 1) = Arr(k, 1) & 1
- Dic(Arr(i, 1)) = 2: Arr(i, 1) = Arr(i, 1) & 2
- Else
- Dic(Arr(i, 1)) = Dic(Arr(i, 1)) + 1: Arr(i, 1) = Arr(i, 1) & Dic(Arr(i, 1))
- End If
- End If
- End If
- Next
- Cells(1, j).Resize(UBound(Arr)) = Arr
- Set Dic = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|