s1 = Worksheets("甲").Cells(1, 1).End(xlDown).Row
s2 = Worksheets("乙").Cells(1, 1).End(xlDown).Row
s3 = Worksheets("統計").Cells(1, 1).End(xlDown).Row
s3_1 = Worksheets("統計").Cells(10000, 8).End(xlUp).Row
s3_2 = Worksheets("統計").Cells(10000, 9).End(xlUp).Row
w = MsgBox("請問要從統計第一天起開始更新", vbYesNoCancel, "!!")
If w = vbYes Then
xx = 2
ElseIf w = vbNo Then
xx = Application.Max(s3_1, s3_2)
ElseIf w = vbCancel Then
b = MsgBox("取消更新!", vbOKOnly, "!!")
Exit Sub
End If
For x3 = xx To s3
up = Worksheets("統計").Cells(x3, 1)
For x1 = 2 To s1
If up = Worksheets("甲").Cells(x1, 1) Then
q1 = x1
End If
Next x1
For x2 = 2 To s2
If up = Worksheets("乙").Cells(x2, 1) Then
q2 = x2
End If
Next x2
Worksheets("統計").Cells(x3, 2) = Worksheets("甲").Cells(q1, 12)
Worksheets("統計").Cells(x3, 3) = Worksheets("乙").Cells(q2, 12)
Next x3
b = MsgBox("資料擷取完成!", vbOKOnly, "!!")
End Sub
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/) |