|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 活在理想的世界 于 2017-8-20 17:07 编辑
应该还有个李子吧?加上李子总数才能对上否则总数对不上的。
只做了一问,第二问跟第一问一样,只要再加个OR的语句就可以了。
- Sub d()
- Dim arr(), brr(), crr(), drr(), d As New Dictionary, w As WorksheetFunction
- Set w = WorksheetFunction
- k = Sheet1.Range("a1048576").End(3).Row - 1
- h = Sheet1.Range("a1").End(2).Column
- arr = Sheet1.Range("a2").Resize(k, h)
- drr = w.Transpose(Sheet2.Range("f1").Resize(1, 3))
- For i = 1 To UBound(arr)
- d(arr(i, 1) & "*" & arr(i, 3) & "*" & arr(i, 6)) = ""
- Next
- ReDim brr(1 To d.Count, 1 To 3)
- ReDim crr(1 To d.Count, 1 To 3)
- For Each i In d.Keys
- s = s + 1
- For j = 1 To 3
- brr(s, j) = Split(i, "*")(j - 1)
- Next
- Next
- For j = 1 To UBound(arr)
- For i = 1 To UBound(brr)
- For n = 1 To UBound(drr)
- If arr(j, 1) = brr(i, 1) And arr(j, 3) = brr(i, 2) And arr(j, 6) = brr(i, 3) And InStr(arr(j, 8), drr(n, 1)) > 0 Then
- crr(i, n) = crr(i, n) + arr(j, 9)
- End If
- Next
- Next
- Next
- Sheet2.Range("f2").Resize(d.Count, 3) = crr
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|