|
2024年第一天,完成运输数据表的汇总统计。- Sub ykcbf2() '//2024.1.1
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("运输数据")
- p = ThisWorkbook.Path
- f = p & "\2024年运输请款单.xlsx"
- Set wb = Workbooks.Open(f, 0)
- For Each sht In wb.Sheets
- If Val(sht.Name) Then
- With sht
- yf = sht.Name & "月"
- r = .UsedRange.Find("请款方").Row - 4
- arr = .Range("a1:k" & r)
- For i = 4 To UBound(arr)
- For j = 2 To 4
- s = yf & "|" & arr(i, 1) & "|" & Trim(arr(3, j))
- d(s) = Val(arr(i, j))
- Next
- Next
- End With
- End If
- Next
- wb.Close False
- With sh
- arr = .[a1:m48]
- For i = 1 To UBound(arr) Step 16
- st = Left(Trim(arr(i, 1)), 1)
- For j = 2 To UBound(arr, 2)
- Sum = 0
- For x = 3 To 14
- s = arr(i + x - 1, 1) & "|" & arr(i + 1, j) & "|" & st
- If d.exists(s) Then
- arr(i + x - 1, j) = d(s)
- Else
- arr(i + x - 1, j) = 0
- End If
- Sum = Sum + arr(i + x - 1, j)
- Next
- arr(i + 14, j) = Sum
- Next
- Next
- .[a1:m48] = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|