|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下。。。。
Sub HHHHH()
With Sheet2
.[G4:M1040000] = ""
Set d = CreateObject("Scripting.Dictionary")
Dim i As Long
arr = Worksheets("物料收发汇总表").Range("b2:e" & Worksheets("物料收发汇总表").Range("b1040000").End(xlUp).Row)
ReDim brr(1 To Worksheets("物料收发汇总表").Range("b1040000").End(xlUp).Row - 1, 1 To 7)
crr = .Range("g3:m3").Value
drr = .Range("a4:a7")
For i = 1 To UBound(drr)
If drr(i, 1) <> Empty Then d(drr(i, 1)) = i
Next
For i = 1 To UBound(arr)
If d.exists(arr(i, 1)) Then
m = d(arr(i, 1))
If arr(i, 4) = crr(1, 1) Then
brr(m, 1) = brr(m, 1) + arr(i, 3)
ElseIf arr(i, 4) = crr(1, 2) Then
brr(m, 2) = brr(m, 2) + arr(i, 3)
ElseIf arr(i, 4) = crr(1, 3) Then
brr(m, 3) = brr(m, 3) + arr(i, 3)
ElseIf arr(i, 4) = crr(1, 4) Then
brr(m, 4) = brr(m, 4) + arr(i, 3)
ElseIf arr(i, 4) = crr(1, 5) Then
brr(m, 5) = brr(m, 5) + arr(i, 3)
ElseIf arr(i, 4) = crr(1, 6) Then
brr(m, 6) = brr(m, 6) + arr(i, 3)
ElseIf arr(i, 4) = crr(1, 7) Then
brr(m, 7) = brr(m, 7) + arr(i, 3)
End If
End If
Next
.Range("g4:m" & d.Count + 3) = brr 'WorksheetFunction.Transpose(brr)
End With
Set d = Nothing
Beep
End Sub
|
评分
-
1
查看全部评分
-
|