|
楼主 |
发表于 2024-9-2 15:32
|
显示全部楼层
Sub bb()
Application.ScreenUpdating = False
On Error Resume Next
t = Timer
Dim arr, brr, n, k
n = Sheet1.Range("A65535").End(xlUp).Row
arr = Sheet1.Range(("a1:a") & n)
ReDim brr(2 To n, 1 To 2)
For i = 1 To n '数组赋值
'brr(i) = brr(i) = Left(arr(i, 1), Len(arr(i, 1)) - 3)
brr(i, 1) = Left(arr(i, 1), Len(arr(i, 1)) - 3) '去掉最后3位的值
Next i
Sheet1.[b2].Resize(n, 1) = brr '生产批号赋值
For i = 2 To n '统计相同批号的钢瓶个数
If brr(i, 1) = brr(i + 1) Then
k = k + 1
Else
Cells(i, 3) = k
k = 1
End If
Next i
MsgBox "用时" & Format((Timer - t), "#0.00") & "秒"
Application.ScreenUpdating = True
End Sub
这样只能运行到生产批号赋值 |
|