|
全部代码如下:
- Sub Other_Hour() '//2024.8.30
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- p = ThisWorkbook.Path & ""
- Set sh = ThisWorkbook.Sheets("Individual")
- f = p & "其他时间_20240829163723.xlsx"
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .Cells(1, "XFD").End(1).Column
- arr = .[a1].Resize(r, c)
- End With
- wb.Close 0
- For i = 2 To UBound(arr)
- rq = CDate(Split(arr(i, 7))(0)) '//日期格式先处理
- s = CStr(arr(i, 2)) & "|" & CDate(rq)
- d(s) = d(s) + Val(arr(i, 4))
- Next
- With sh
- r = .Cells(Rows.Count, 2).End(3).Row
- For i = 232 To r
- For j = 216 To 246
- s = CStr(.Cells(i, 2).Value) & "|" & CDate(.Cells(231, j).Value)
- If d.exists(s) Then
- .Cells(i, j).Value = d(s)
- Else
- .Cells(i, j).Value = ""
- End If
- Next
- Next
- ActiveWindow.DisplayZeros = False
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- ' MsgBox "OK!"
- End Sub
复制代码
|
|