|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
zhangguochang 发表于 2014-2-24 23:34
你看看这个就明白了
请测试:- Sub 字典加数组()
- Dim arr, brr(), sh As Worksheet, d As Object, k, t, a, i&, j&, m&, l&, s$, rng As Range
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- For i = 6 To UBound(arr) - 1
- s = arr(i, 3)
- d(s) = d(s) & "," & i
- Next
- k = d.Keys
- t = d.Items
- For Each sh In Sheets
- If sh.Name <> "总表" Then sh.Delete
- Next
- Set sh = Sheets("总表")
- For i = 0 To d.Count - 1
- a = Split(t(i), ",")
- ReDim brr(1 To UBound(a), 1 To 11)
- For j = 1 To UBound(a)
- For l = 1 To 10
- r = a(j)
- brr(j, l) = arr(r, l)
- Next
- brr(j, 11) = arr(r, 15)
- Next
- sh.Copy After:=Sheets(Sheets.Count)
- With ActiveSheet
- For Each shp In .Shapes
- shp.Delete
- Next
- .Name = k(i)
- .Columns("L:O").Delete Shift:=xlToLeft
- .[K4] = k(i)
- .[K5] = sh.Rows(4).Find(k(i), , , 1).Offset(1).Value
- .Cells(6, 1).Resize(j - 1, 11) = brr
- .UsedRange.Offset(j + 4).Clear
- End With
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|