|
代码以附件为准- Sub ykcbf() '//2024.1.31
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("名字明细")
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a1:n" & r)
- For i = 5 To 13
- s = arr(i, 1)
- If s <> Empty Then
- For j = 3 To UBound(arr, 2)
- ss = arr(i, 2) & "|" & Format(arr(4, j), "d-mmm")
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(ss) = arr(i, j)
- Next
- End If
- Next
- For i = 18 To UBound(arr)
- s = arr(i, 1)
- If s <> Empty Then
- For j = 3 To UBound(arr, 2)
- ss = arr(i, 2) & "|" & Format(arr(17, j), "d-mmm")
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(ss) = arr(i, j)
- Next
- End If
- Next
- End With
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a1:n" & r)
- For i = 6 To UBound(arr)
- s = .Name
- If arr(i, 1) <> Empty And InStr(arr(i, 1), "TOTAL") = 0 Then
- For j = 2 To UBound(arr, 2)
- ss = arr(i, 1) & "|" & Format(arr(4, j), "d-mmm")
- If d.exists(s) Then
- arr(i, j) = d(s)(ss)
- End If
- Next
- End If
- Next
- .Range("a1:n" & r) = arr
- End With
- End If
- Next
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|