P = InputBox("請輸入MO [Please enter MO]", "請輸入MO [Please enter MO]", "")
If Len(P) < 7 Then
If MsgBox("你的輸入有誤,是否重新輸入一個MO?" & vbCrLf & _
"點擊""是""重新輸入,""否""退出當次輸入。" & vbCrLf & _
"You are not enter MO ,Click ""是(Y)""Re-enter or ""否(N)""End enter", vbYesNo Or vbQuestion, "無輸入MO [You are not enter MO]") = vbYes Then GoTo EnterMOo
Exit Sub
End If
EnterOID:
G = InputBox("請輸入工號 [Please enter OP ID]", "請輸入工號 [Please enter OP ID]", "")
If Len(G) < 1 Then
If MsgBox("你的輸入有誤,是否重新輸入工號?" & vbCrLf & _
"點擊""是""重新輸入,""否""退出當次輸入。" & vbCrLf & _
"You are not enter OP ID ,Click ""是(Y)""Re-enter or ""否(N)""End enter", vbYesNo Or vbQuestion, "無輸入工號 [You are not enter OP ID]") = vbYes Then GoTo EnterOID
Exit Sub
End If
Dim C2 As Integer
C2 = 2
While Cells(C2, 2) <> ""
C2 = C2 + 1
Wend
Cells(C2, 6) = Now()
Cells(C2, 7) = G
End Sub
複製代碼
另再問一下 如果刪除功能,要改成比對F欄位 超過3個月
程式碼該如何修改呢?
Sub 刪除()
Dim R&
R = Application.CountIf([Database!C:C], "<" & Date - 90)
If R > 0 Then [Database!A2:C2].Resize(R).Delete Shift:=xlUp
R = Application.CountIf([Database!F:F], "<" & Date - 90)
If R > 0 Then [Database!D2:F2].Resize(R).Delete Shift:=xlUp