|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 测试()
- Dim i%, j%, k%, m%, n%, arr, brr, crr, drr
- Dim dic As Object, key, keys, items
- Set dic = CreateObject("scripting.dictionary")
- Dim dic1 As Object, key1, keys1, items1
- Set dic1 = CreateObject("scripting.dictionary")
- arr = Sheet1.Range("A1:L" & Sheet1.Cells(Rows.Count, "A").End(xlUp).Row)
- For i = 2 To UBound(arr)
- If arr(i, 1) <> "" Then
- key1 = arr(i, 2)
- dic1(key1) = ""
- For j = 3 To UBound(arr, 2)
- key = arr(i, 2) & "," & arr(1, j)
- If arr(i, j) = "优" Then
- dic(key) = dic(key) + 1
- End If
- Next
- End If
- Next
- keys1 = dic1.keys
- Range("N2").Resize(dic1.Count, 1) = Application.Transpose(dic1.keys)
- brr = Range("N1").CurrentRegion.Value
- For i = 2 To UBound(brr)
- For j = 2 To UBound(brr, 2)
- key = brr(i, 1) & "," & brr(1, j)
- brr(i, j) = dic(key)
- Next
- Next
- Range("N1").Resize(UBound(brr), UBound(brr, 2)) = brr
- End Sub
复制代码 |
|