Dim xB As Workbook
On Error Resume Next '以下三行可以檢查FQC是否開啟中
Set xB = Workbooks("FQC")
On Error GoTo 0
If xB Is Nothing Then Set xB = Workbooks.Open(ThisWorkbook.Path & "\FQC.xls") '若未開啟,執行開啟檔案(避免重覆開啟而當機)
Set xE = xB.Sheets("input").[A65536].End(xlUp)(2)
If xE.Row < 6 Then Set xE = xE(2)
xE.Resize(2, 39) = Brr
xB.Close 1 '關閉FQC, 並存檔作者: dea172 時間: 2018-4-18 14:31
For i = 0 To UBound(Arr) - 1
If Arr(i + 1, 1) = "P" Then
'這裡空白即可(不做任何動作)
ElseIf Arr(i + 1, 1) = "M" Then
For j = 5 To 6: Brr(1, i * 3 + j) = Arr(i + 1, j + 1): Next j '只抓前2格
Else
For j = 5 To 7: Brr(1, i * 3 + j) = Arr(i + 1, j + 1): Next j '抓前3格
For j = 5 To 6: Brr(2, i * 3 + j) = Arr(i + 1, j + 4): Next j '抓後2格
End If
Next i作者: 准提部林 時間: 2018-4-19 16:43
為了防呆,在程式碼的前端再加這三行:
If IsDate([C1]) = False Then MsgBox "日期格式錯誤或未輸入!!": Exit Sub
If [E1] = "" Then MsgBox "Machine No 未輸入!!": Exit Sub
If [G1] Like "########-####" = False Then MsgBox "Lot No 錯誤或未輸入!!": Exit Sub作者: dea172 時間: 2018-4-19 16:59