|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.7.29
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("求和")
- On Error Resume Next
- For Each sht In Sheets
- If Val(sht.Name) Then
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- c1 = Application.WorksheetFunction.Match(UCase("ID"), .Rows(1), 0)
- c2 = Application.WorksheetFunction.Match("日期", .Rows(1), 0)
- c3 = Application.WorksheetFunction.Match("金额", .Rows(1), 0)
- arr = .[a1].Resize(r, c)
- End With
- For i = 2 To UBound(arr)
- s = CStr(arr(i, c1)) & "|" & Format(arr(i, c2), "yyyy-mm-dd")
- d(s) = d(s) + arr(i, c3)
- Next
- End If
- Next
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 3)
- For i = 2 To UBound(arr)
- rq = CDate(arr(i, 1))
- s = CStr(arr(i, 2)) & "|" & arr(i, 1)
- If d.exists(s) Then
- arr(i, 3) = d(s)
- End If
- Next
- .[c1].Resize(r, 1) = Application.Index(arr, 0, 3)
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|