|
- Sub test()
- Dim r%, i%, c%, j%
- Dim arr, brr
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Worksheets(1)
- c = .Cells(2, .Columns.Count).End(xlToLeft).Column
- For j = 2 To c Step 5
- r = .Cells(.Rows.Count, j).End(xlUp).Row
- r1 = r + 1
- For i = r To 3 Step -1
- If .Cells(i, j + 4) <> .Cells(i - 1, j + 4) Then
- .Cells(r1, j).Resize(1, 5).Insert shift:=xlDown
- .Cells(r1, j + 2) = "小计"
- .Cells(r1, j + 3) = "=SUM(R" & i & "C:R[-1]C)"
- .Cells(r1, j + 4) = .Cells(r1 - 1, j + 4)
- r1 = i
- End If
- Next
- Next
- End With
- End Sub
复制代码 |
|