|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
.....
- Sub test()
- Dim arr, brr, brr1, crr, d, i&, ii&, j&, n&, k
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- arr = Range("B3:D" & Cells(Rows.Count, 2).End(xlUp).Row) '确定数组范围
- brr = Array("3A", "3B", "3C", "3D", "3E", "3F", "2G", "2H", "2J", "3G", "3H", "3J") '指定条件,但不知指定第二个条件“组别”????
- brr1 = Array("A", "B", "C")
- ReDim crr(1 To UBound(arr), 1 To UBound(arr, 2))
- For i = 0 To UBound(brr)
- For ii = 0 To UBound(brr1)
- d(brr(i) & brr1(ii)) = ""
- Next ii
- Next i
- For i = 1 To UBound(arr)
- k = i & "," & arr(i, 1) & arr(i, 2)
- d1(k) = i
- Next
- n = 0
- For Each k In d
- temp = Filter(d1.keys, k)
- For i = 0 To UBound(temp)
- n = n + 1
- For j = 1 To 3
- crr(n, j) = arr(d1(temp(i)), j)
- Next j
- Next
- Next
- Range("M3").Resize(UBound(crr), UBound(crr, 2)) = crr
- End Sub
复制代码 |
|