|
修改一下,适应不同年份。
- Sub ykcbf() '//2024.5.29
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set sh = ThisWorkbook.Sheets("汇总")
- Set d = CreateObject("Scripting.Dictionary")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 6)
- For i = 3 To UBound(arr)
- nf = Year(arr(i, 1))
- yf = CheckMonth(arr(i, 1), 25)
- s = nf & "|" & yf & "|" & UCase(arr(i, 3)) & "|" & arr(i, 4)
- d(s) = d(s) + arr(i, 6)
- Next
- End With
- End If
- Next
- With sh
- .[o3:z1000] = ""
- r = .Cells(Rows.Count, "e").End(3).Row
- arr = .[a1].Resize(r, 38)
- For i = 3 To UBound(arr)
- For j = 15 To UBound(arr, 2)
-
- s = Val(arr(1, j)) & "|" & arr(2, j) & "|" & UCase(arr(i, 5)) & "|" & arr(i, 6)
- If d.exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- .[a1].Resize(r, 38) = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|