本帖最后由 cutecpu 于 2021-11-2 01:51 编辑
我从 '變量定義: n(行號),x(數據源循環總行數) ,t1(計算時間) ...........
以下代码开始改写
Sub demo3()
Dim n, x,t1, t2, t3, t4, t5, T, F, L, run1, run2
n = 2: x =Sheets("研磨数据源").[A1].end(3).row t1 =Sheets("研磨粉run数").[A65536].End(xlUp)
WithSheets("研磨数据源")
For n = nTo x t2 =.Cells(n, 79).Value If t1<> t2 Or t2 = "" Or .Cells(n, 27).Value <> 1 Then GoTo 1 If.Cells(n, 16).Value = .Cells(n - 1, 16).Value Then run1= .Cells(n - 1, 27).Value run2= .Cells(n - 1, 28).Value Select Case run1 Case Is = run2 T = T + 1: s = "研磨液达标" Case Is < run2 F = F + 1: s = "研磨液不达标" Case Is > run2 L = L + 1: s = "研磨液超标" EndSelect .Cells(n - 1, 26) = s t3 =t3 + run2 t4 =t4 + run1 Else t5 =t5 + 1 .Cells(n,28) = "研磨液达标?" End If 1: Next
End With
WithSheets("研磨粉run数") .[B65536].End(3).Resize(, 8) = Array(T, F, L, t4, t3, t4 / t3,"100%", t5) .Activate End With
End Sub
|