|
把插入空行加上了,毕竟刚学,代码不是太好,凑合用吧- Sub shishi()
- Dim crr(1 To 10000, 1 To 13)
- Set dic = CreateObject("Scripting.Dictionary")
- With Sheets("客户月度出货列表")
- R = .Cells(Rows.Count, "a").End(xlUp).Row
- c = .Cells(1, Columns.Count).End(xlToLeft).Column
- arr = .Range("a1").Resize(R, c)
- End With
- For i = 2 To UBound(arr)
- If arr(i, 2) <> "" Then
- If arr(i, 2) = [q1] Then
- n = n + 1
- For j = 1 To UBound(arr, 2)
- crr(n, j) = arr(i, j)
- crr(n, 10) = VBA.Round(arr(i, 9) + arr(i, 8), 0)
- Next j
- End If
- End If
-
- Next i
- i = Cells(Rows.Count, "a").End(xlUp).Row
- Range("a2:p10000").Clear
- Range("a2").Resize(n, 13) = crr
- Range("n2") = "=j2-l2+r1"
- Range("n3") = "=j3-l3+n2"
- Range("n3").AutoFill Range("n3:n" & i)
- For j = i To 2 Step -1
- If Cells(j, 13) <> Cells(j - 1, 13) Then
- Rows(j).Select
- Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
- End If
- Next
- End Sub
复制代码 |
|