excel怎么排序?
以下代码是excelVBA中的代码,
Sub autoNumber()
Dim max_row As Long
Dim i As Long
Dim cur_number As Long
Dim content As String
Dim d As Object
Set d = CreateObject("scripting.dictionary")
cur_number = 1
'获得A列非空最大行号
max_row = Range("A65535").End(3).Row
For i = 2 To max_row
If d.Exists(Cells(i, "A").Value) Then
'从字典中取出编号
Sheets("Sheet3").Cells(i, "B") = d.Item(Cells(i, "A"棚拦).Value)
Else
'新添加编号
Sheets("Sheet3").Cells(i, "B").Value = cur_number
content = Sheets("Sheet3").Cells(i, "A").Value
'将新编号存到字链碰胡典中
d.Add content, cur_number
'编号+1
吵档 cur_number = cur_number + 1
End If
Next
End Sub