藍色部份,新增、修改!
Sub mo()
If Sheet1.OptionButton1 Then Set sjsht = Sheet5
If Sheet1.OptionButton2 Then Set sjsht = Sheet3
If Sheet1.OptionButton3 Then Set sjsht = Sheet2
If Sheet1.OptionButton4 Then Set sjsht = Sheet4
If Sheet1.OptionButton5 Then Set sjsht = Sheet6
a = Range("a5:
aw" & Cells(Rows.Count, 1).End(xlUp).Row)
With sjsht
b = .Range("a3:
aw" & .Cells(Rows.Count, 1).End(xlUp).Row)
End With
Set d = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(a)
d.Add a(i, 3) & "," & a(i, 6), i
For j = 17 To 27
If a(i, j) <> "" Then a(i, j + 22) = Now
Next
Next
For i = 1 To UBound(b)
Key = b(i, 3) & "," & b(i, 6)
If d.exists(Key) Then
r = d(Key)
For j = 1 To UBound(a, 2)
b(i, j) = a(r, j)
Next
End If
Next
Application.EnableEvents = False
sjsht.Range("a3").Resize(UBound(b), UBound(b, 2)) = b
Application.EnableEvents = True
Sheet1.Range("a5").Resize(UBound(a), UBound(a, 2)).ClearContents
End Sub
祝順心,南無阿彌陀佛!