|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%, m%
- Dim arr, brr, zrr()
- Dim xm$
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("表1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a4:j" & r)
- ReDim brr(1 To UBound(arr), 1 To 1)
- For i = 1 To UBound(arr)
- For j = 7 To 10
- brr(i, 1) = brr(i, 1) & IIf(Len(arr(i, j)) = 0 Or arr(i, j) = 0, "0", "1")
- Next
- Next
- xm = Empty
- s = 0
- m = 0
- For i = 1 To UBound(brr)
- If brr(i, 1) <> xm Or arr(i, 1) <> s Then
- m = m + 1
- ReDim Preserve zrr(1 To m)
- zrr(m) = Array(i, i)
- Else
- If m > 0 Then
- zrr(m)(1) = i
- End If
- End If
- xm = brr(i, 1)
- s = arr(i, 3)
- Next
- ReDim crr(1 To UBound(zrr), 1 To UBound(arr, 2))
- For k = 1 To UBound(zrr)
- crr(k, 1) = arr(zrr(k)(0), 1)
- crr(k, 2) = arr(zrr(k)(0), 2)
- crr(k, 3) = arr(zrr(k)(1), 3)
- For j = 7 To 10
- For i = zrr(k)(0) To zrr(k)(1)
- crr(k, j) = crr(k, j) + arr(i, j)
- Next
- Next
- Next
- .Range("w4").Resize(UBound(crr), UBound(crr, 2)) = crr
-
- End With
- End Sub
复制代码 |
|