|
参与一下。。。
- Sub ykcbf() '//2024.9.13
- r = Cells(Rows.Count, 1).End(3).Row
- arr = [a2].Resize(r - 1, 5)
- [h2].Resize(UBound(arr), UBound(arr, 2)) = arr
- arr = [h1].Resize(r, 5)
- ReDim brr(1 To r, 1 To 5)
- ReDim zrr(1 To 10000)
- For i = 3 To UBound(arr)
- If arr(i, 5) <> arr(i - 1, 5) Then m = m + 1: zrr(m) = Array(i, i)
- If i = r Then zrr(m)(1) = r
- If i < r Then
- If arr(i, 5) = arr(i - 1, 5) And arr(i, 5) <> arr(i + 1, 5) Then zrr(m)(1) = i
- End If
- Next
- For x = 1 To m
- r1 = zrr(x)(0): r2 = zrr(x)(1)
- n = r2 - r1 + 1
- If n > 1 Then
- Cells(r1, "k") = Application.Sum(Cells(r1, "k").Resize(n))
- Cells(r1 + 1, "h").Resize(n - 1, 5) = ""
- End If
- Next
- End Sub
复制代码
|
|