請測試看看,謝謝
Sub test()
Dim Arr, xD, T$, i&
Set xD = CreateObject("Scripting.Dictionary")
Arr = Range([比!an1], [比!e63356].End(3))
For i = 4 To UBound(Arr)
T = Arr(i, 1)
xD(T) = Array(Arr(i, 5), Arr(i, 6), Arr(i, 12), Arr(i, 16), Arr(i, 33), Arr(i, 36))
Next
With Sheets("新月")
Arr = .Range(.[j1], .[a63356].End(3))
For i = 4 To UBound(Arr)
T = Arr(i, 1)
If xD.Exists(T) Then
Arr(i, 5) = xD(T)(0): Arr(i, 6) = xD(T)(1): Arr(i, 7) = xD(T)(2)
If xD(T)(4) <> "" Then Arr(i, 9) = IIf(xD(T)(4) Mod 2, "V", "O")
Arr(i, 10) = IIf(xD(T)(5) > 0, "V", "")
End If
Next
.[a1].Resize(UBound(Arr), 10) = Arr
End With
End Sub作者: PJChen 時間: 2021-11-2 20:14
Sub TEST_A1()
Dim Arr, Brr, xD, i&, j%, R&, V
Set xD = CreateObject("Scripting.Dictionary")
Arr = Range([比!an1], [比!e63356].End(3)(2)) '範圍--向下多取一行空白列, 若比對不到就利用這行填入空白
For i = 4 To UBound(Arr) - 1
xD(Arr(i, 1) & "") = i: V = Arr(i, 33)
If V > 0 Then Arr(i, 33) = IIf(V Mod 2, "V", "O")
Arr(i, 36) = IIf(Arr(i, 36) > 0, "V", "")
Next
Brr = Range([新月!j1], [新月!a63356].End(3))
For i = 4 To UBound(Brr)
R = xD(Brr(i, 1) & ""): If R = 0 Then R = UBound(Arr)
For j = 1 To 6
Brr(i - 3, j) = Arr(R, Array(5, 6, 12, 16, 33, 36)(j - 1))
Next j
101: Next i
[新月!e4].Resize(UBound(Brr) - 3, 6) = Brr
End Sub作者: PJChen 時間: 2021-11-8 17:10
Brr = Range([新月!K1], [新月!a63356].End(3))
For i = 4 To UBound(Brr)
R = xD(Brr(i, 1) & ""): If R = 0 Then R = UBound(Arr)
For j = 1 To 7
If j <> 4 Then Brr(i - 3, j) = Arr(R, Array(5, 14, 12, "", 33, 36, 11)(j - 1))
Next
Brr(i - 3, 4) = ""
Next i
[新月!e4].Resize(UBound(Brr) - 3, 7) = Brr