|
一任清风 发表于 2013-4-20 14:19
哪位老师帮帮忙 - Sub hbhz()
- Set d = CreateObject("scripting.dictionary")
- Set a = Sheets("汇总"): Set b = Sheets("全体")
- b.Range("a3:d" & b.Range("a" & Rows.Count).End(3).Row + 1).Clear
- For Each sh In Sheets
- If sh.Name <> "汇总" And sh.Name <> "全体" Then
- x = b.Range("a" & Rows.Count).End(3).Row + 1
- y = sh.Range("a" & Rows.Count).End(3).Row
- sh.Range("a3:d" & y).Copy b.Range("a" & x)
- End If
- Next
- arr = b.UsedRange
- ReDim brr(1 To UBound(arr), 1 To 4)
- For i = 3 To UBound(arr)
- k = Application.Match(arr(i, 4), Rows(2), 0)
- If Not d.Exists(arr(i, 1)) Then
- m = m + 1: d(arr(i, 1)) = m: brr(m, 1) = arr(i, 1)
- brr(m, k) = 1
- Else
- brr(d(arr(i, 1)), k) = brr(d(arr(i, 1)), k) + 1
- End If
- Next
- a.Range("a3").Resize(m, 4) = brr
- a.[a2].Resize(m + 1, 4).Borders.LineStyle = xlContinuous
- End Sub
复制代码 |
|