|
- Sub a()
- Application.ScreenUpdating = False
- Sheet4.Cells.Clear
- Sheet4.Cells.Delete Shift:=xlUp
- Sheet1.Columns("A:G").Copy
- With Sheet4
- .[a1].PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- .[a1].CurrentRegion.Sort key1:=.[c1], order1:=xlAscending, Header:=xlNo '最先操作是按部门排序
- Call 宏6
-
- '原始参数和数据获取
- ar = .UsedRange: ua = UBound(ar): ua2 = UBound(ar, 2)
- Set d = CreateObject("scripting.dictionary") '字典:总箱子数
-
- For i = 1 To ua
- d(ar(i, 3)) = ""
- Next i
- zxzs = d.Count '总箱子个数
-
- Set bw = Sheet3.Rows("1:2")
- Set bt = Sheet3.Rows("3:6")
-
-
- '表格制作
- For i = ua To 1 Step -1
- If i = ua Then
- bw.Copy
- .Rows(ua + 1).Insert
- ElseIf i = 1 Then
- bt.Copy
- .Rows(1).Insert
- ElseIf ar(i, 3) <> ar(i - 1, 3) Then
- bt.Copy
- .Rows(i).Insert
- bw.Copy
- .Rows(i).Insert
- End If
- Next i
- '表格美化
- br = .UsedRange: ub = UBound(br): Kc = 0
-
- For i = 1 To ub
- If br(i, 1) = "序号" Then
- xc = 0
- ElseIf br(i, 1) Like "共*箱" Then
- Kc = Kc + 1
- .Cells(i, 1) = "共" + Str(zxzs) + "箱 第" + Str(Kc) + "箱"
- ElseIf br(i, 1) = "合计" Then
- .Cells(i, 7) = xc
- ElseIf VBA.IsNumeric(br(i, 1)) Then
- xc = xc + br(i, 7)
- End If
- Next i
- .Columns("A:G").EntireColumn.AutoFit
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|