|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim ws As Worksheet
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Worksheets("应收账")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a1").Resize(r, c)
- End With
- For j = 2 To UBound(arr, 2) - 1
- ReDim brr(1 To UBound(arr), 1 To 4)
- m = 0
- s = 0
- For i = 2 To UBound(arr)
- If arr(i, 1) <> "消费金额" And Len(arr(i, j)) <> 0 Then
- m = m + 1
- brr(m, 1) = m
- brr(m, 2) = arr(i, 1)
- brr(m, 3) = arr(i, j)
- s = s + arr(i, j)
- End If
- Next
- If m > 0 Then
- m = m + 1
- brr(m, 2) = "合计"
- brr(m, 3) = s
- shtname = CStr(Day(arr(1, j)))
- On Error Resume Next
- Set ws = Worksheets(shtname)
- If Err Then
- Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
- ws.Name = shtname
- End If
- On Error GoTo 0
- With ws
- .Cells.Clear
- With .Range("a1")
- .Value = "签单明细表"
- .Resize(1, 4).Merge
- With .Font
- .Name = "微软雅黑"
- .Size = 16
- .Bold = True
- End With
- End With
- .Range("a2") = "日期:"
- With .Range("b2")
- .Value = arr(1, j)
- .NumberFormatLocal = "yyyy年m月d日"
- End With
- .Range("a3:d3") = Array("序号", "单位", "金额", "备注")
- .Range("a4").Resize(m, 4) = brr
- With .Range("a3").Resize(1 + m, 4)
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- End With
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- .Range("b2").HorizontalAlignment = xlLeft
- .Columns(1).ColumnWidth = 7
- .Columns(2).ColumnWidth = 30
- .Columns(3).ColumnWidth = 7
- .Columns(4).ColumnWidth = 15
-
- End With
- End If
- Next
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|