- Sub 测试()
- Dim i%, j%, k%, m%, n%, arr, brr, crr, drr
- Dim rng As Range, sht As Worksheet, wbk As Workbook
- Dim dic As Object, key, keys, items
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet1.Range("A1").CurrentRegion.Value
- For i = 2 To UBound(arr)
- key = arr(i, 2) & "," & arr(i, 3)
- For j = 3 To UBound(arr, 2)
- If arr(i, j) = "达标" Then
- dic(key) = dic(key) + 1
- End If
- Next
- Next
- keys = dic.keys
- ReDim brr(1 To dic.Count, 1 To 4)
- For i = LBound(keys) To UBound(keys)
- brr(i + 1, 1) = i + 1
- brr(i + 1, 2) = Split(keys(i), ",")(0)
- brr(i + 1, 3) = Split(keys(i), ",")(1)
- brr(i + 1, 4) = dic.items()(i)
- Next
- Sheet2.Range("A2").Resize(dic.Count, 4) = brr
- End Sub
复制代码 |