|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
1.已进行事项:Defect name,Stage,Hour使用字典法已计算出想要的数量,但这是整体的2.咨询事项:
①想设置一弹窗(即input),提示输入Line(如#210或#211等),然后字典法(重复已进行的事项)计算出的数量即为#210或#211中的数量
②想要得到除去“OK”产品的数量,即不良数量,如何编写(不想用sum,速度慢)
以下为具体不良名的和检查数的数量code
Sub buliangmingtest()
tms = Timer
Dim i, j, s, d, arr, brr
Set d = CreateObject("Scripting.Dictionary")
arr = Sheet4.[a1].CurrentRegion
For i = 2 To UBound(arr)
s = arr(i, 2) & arr(i, 3) & arr(i, 4)
If Not d.exists(s) Then d(s) = arr(i, 5)
Else d(s) = d(s) + arr(i, 5)
End If
Next
brr = [a1].CurrentRegion
For i = 3 To UBound(brr)
For j = 2 To 17 I
f Cells(1, j).MergeCells Then brr(1, j) = Cells(1, j).MergeArea.Cells(1, 1)
s = brr(i, 1) & brr(2, j) & brr(1, j)
End If
If d.exists(s) Then brr(i, j) = d(s)
Next
Next
[a1].CurrentRegion = brr
MsgBox Format(Timer - tms, "0.0000s")
End Sub
Sub jianchashutest()
tms = Timer
Dim i, j, s, d, arr, brr
Set d = CreateObject("Scripting.Dictionary")
arr = Sheet4.[a1].CurrentRegion
For i = 2 To UBound(arr) s = arr(i, 3) & arr(i, 4)
If Not d.exists(s) Then d(s) = arr(i, 5)
Else d(s) = d(s) + arr(i, 5)
End If
Next
brr = [a1].CurrentRegion
For j = 2 To 17
If Cells(1, j).MergeCells Then brr(1, j) = Cells(1, j).MergeArea.Cells(1, 1)
s = brr(2, j) & brr(1, j)
End If
If d.exists(s) Then brr(3, j) = d(s)
Next
[a1].CurrentRegion = brr
MsgBox Format(Timer - tms, "0.0000s")
End Sub
|
-
-
|