|
楼主 |
发表于 2024-9-19 09:47
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
老师:以下是我自己理解翻译的,不知道对不对呀,请指正!
Set w1 = Sheet1: Set w2 = Sheet2: Set w3 = Sheet3
w2.[a3:e10000].Delete Shift:=xlUp '//以下向上删除所选单元格或区域
w3.[a3:e10000].Delete Shift:=xlUp
Set d = CreateObject("scripting.dictionary") '//定义字典
arr = w1.Range("a1").CurrentRegion '//Ctrl + a1 范围内的数组
'汇总
For i = 2 To UBound(arr) - 1 '//去除最后一行时间总和
x = arr(i, 2) & "|||" & arr(i, 3) '// 指定工令号和子项号为关键字?
If Not d.exists(x) Then '//如果字典中指定的关键字不存在
d(x) = Array(arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5)) '//则定义关键子的赋值为B-E的列表
Else
d(x) = Array(d(x)(0), d(x)(1), d(x)(2), d(x)(3) + arr(i, 5)) '//不懂....d(x)(0)是工令号吗?d(x)(3)+arr(i,5)是时间求和吗?
End If
Next i
'输出并排序
w2.[b3].Resize(d.Count, 4) = Application.Transpose(Application.Transpose(d.items)) '//把字典中所有的关键字对应的值赋给以b3单元格开始的单元格区域中
w2.[a1].CurrentRegion.Offset(1).Sort w2.[b3], 2, Header:=1 '//不太懂
w3.[b3].Resize(d.Count, 4) = Application.Transpose(Application.Transpose(d.items))
w3.[a1].CurrentRegion.Offset(1).Sort w3.[b3], 2, Header:=1 |
|