|
参与一下。。。
- Sub ykcbf() '//2024.8.14
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("汇总")
- arr = sh.UsedRange
- For j = 2 To UBound(arr, 2)
- s = arr(1, j)
- d1(s) = j
- Next
- On Error Resume Next
- For Each sht In Sheets
- If Val(sht.Name) Then
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- Set Rng = .UsedRange.Find("生产日期", LookIn:=xlValues)
- bt = Rng.Row: col = Rng.Column
- c = .Cells(bt, "XFD").End(1).Column
- arr = .[a1].Resize(r, c)
- End With
- For i = bt + 1 To UBound(arr)
- rq = FormatDateTime(CDate(arr(i, col)), 2)
- If IsDate(rq) = True Then
- For j = 1 To UBound(arr, 2)
- s1 = arr(bt, j)
- If d1.exists(s1) Then
- s = rq & "|" & s1
- d(s) = d(s) + arr(i, j)
- End If
- Next
- End If
- Next
- End If
- Next
- With sh
- .UsedRange.Offset(1, 1).ClearContents
- arr = .UsedRange
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- s = arr(i, 1) & "|" & arr(1, j)
- If d.exists(s) Then
- arr(i, j) = Round(d(s), 2)
- End If
- Next
- Next
- .UsedRange = arr
- End With
- Set d = Nothing
- Set d1 = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|