|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
simpman 发表于 2014-12-15 10:34
大师再麻烦您一下,表名和灰色部分能不能由手工填写不刷新,汇总部分对应刷新填入,行不行? - Sub yy()
- Sheets("汇总").Activate
- Dim df, dj, arr, i&, k&, n&, f$, j$, s$
- Set df = CreateObject("Scripting.dictionary")
- Set dj = CreateObject("Scripting.dictionary")
- For n = 6 To 12
- df(Mid(Cells(2, n), 3)) = n - 5
- dj(Mid(Cells(2, n + 8), 3)) = n - 5
- Next
- ReDim ar(1 To 999, 1 To 10)
- ReDim br(1 To 999, 1 To 10)
- For k = 3 To [a3].End(4).Row
- s = Cells(k, 1).Value
- arr = Sheets(s).UsedRange.Value
- For i = 2 To UBound(arr)
- If Len(arr(i, 6)) = 0 Then arr(i, 6) = arr(i - 1, 6)
- If Len(arr(i, 10)) = 0 Then arr(i, 10) = arr(i - 1, 10)
- f = arr(i, 6): j = arr(i, 10)
- If df.exists(f) Then ar(k - 2, df(f)) = ar(k - 2, df(f)) + arr(i, 9)
- If dj.exists(j) Then br(k - 2, dj(j)) = br(k - 2, dj(j)) + arr(i, 13)
- Next
- Next
- [f3:l1000,n3:t1000] = ""
- [f3].Resize(k - 2, df.Count) = ar
- [n3].Resize(k - 2, dj.Count) = br
- Set df = Nothing
- Set dj = Nothing
- End Sub
复制代码 |
|