- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- With Sheet1
- r = .Cells(Rows.Count, 2).End(3).Row
- arr = .Range("b2:f" & r).Value
- ReDim brr(1 To 10000, 1 To 100)
- For i = 1 To UBound(arr)
- If arr(i, 3) <> 4 Then
- s = arr(i, 1) & arr(i, 2) & arr(i, 3): s2 = arr(i, 4)
- If Not dic.exists(s) Then
- m = m + 1
- dic(s) = m
- brr(m, 1) = arr(i, 1): brr(m, 2) = arr(i, 2): brr(m, 3) = arr(i, 3)
- If s2 = "A" Then brr(m, 4) = 1: brr(m, 5) = arr(i, 5)
- If s2 = "B" Then brr(m, 6) = 1: brr(m, 7) = arr(i, 5)
- If s2 = "C" Then brr(m, 8) = 1: brr(m, 9) = arr(i, 5)
- Else
- rw = dic(s)
- If s2 = "A" Then brr(rw, 4) = brr(rw, 4) + 1: brr(rw, 5) = brr(rw, 5) + arr(i, 5)
- If s2 = "B" Then brr(rw, 6) = brr(rw, 6) + 1: brr(rw, 7) = brr(rw, 7) + arr(i, 5)
- If s2 = "C" Then brr(rw, 8) = brr(rw, 8) + 1: brr(rw, 9) = brr(rw, 9) + arr(i, 5)
- End If
- End If
- Next
- .[h2].Resize(10000, 9).Clear
- .[h2].Resize(m, 9) = brr
- .[h2].Resize(m, 9).Borders.LineStyle = 1
- .[h2].Resize(m, 9).HorizontalAlignment = xlCenter
- .[h1].Resize(1, 9).Columns.AutoFit
- Beep
- End With
- Set dic = Nothing: Set d2 = Nothing
- End Sub
复制代码 |