|
参与一下。。。- Sub ykcbf() '//2024.5.17
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- rq = Date
- nf = Application.InputBox("请输入查询年份:", "年份", Year(rq))
- With Sheets("客户")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a1").Resize(r, 12)
- End With
- ReDim brr(1 To UBound(arr), 1 To 100)
- brr(1, 1) = nf & "年应收款分客户分月份统计表"
- brr(2, 1) = arr(1, 4)
- m = 2: n = 1
- For i = 2 To UBound(arr)
- If Year(arr(i, 2)) = Val(nf) Then
- s = arr(i, 4)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- End If
- r = d(arr(i, 4))
- s = Month(arr(i, 2)) & "月"
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(2, n) = s
- End If
- c = d(Month(arr(i, 2)) & "月")
- brr(r, c) = brr(r, c) + arr(i, 11)
- End If
- Next
- With Sheets("统计表")
- .UsedRange.Clear
- .[a1].Resize(1, n + 1).Merge
- .[a1].Resize(2, n + 1).Interior.Color = 49407
- .[a3].Resize(m - 1, 1).Interior.Color = 5296274
- With .[a1].Resize(m + 1, n + 1)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- .Cells(2, n + 1) = "合计"
- For i = 3 To m + 1
- .Cells(i, n + 1) = Application.WorksheetFunction.Sum(.Cells(i, 2).Resize(1, n - 1))
- Next
- m = m + 1
- .Cells(m, "a") = "合计"
- .Cells(m, "b").Resize(1, n).FormulaR1C1 = "=SUM(R3C:R" & "[-1]C)"
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|