程式碼下,檔案中請點擊"另存i-Link路徑檔"執行巨集,謝謝幫忙~- Sub 匯出製程至路徑檔()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- If Cells(11, "A") Like "外觀" Then '外觀
- Cells(11, "F").Value = "D,1,1"
- Cells(11, "G").Value = "D,1,2"
- Cells(11, "H").Value = "D,1,3"
- Cells(11, "I").Value = "D,1,4"
- Cells(11, "J").Value = "D,1,5"
- End If
-
- lastRow = Sheets("製程檢查記錄表").Columns(2).Find(What:="", LookIn:=xlValues, _
- SearchDirection:=xlNext, AFTER:=Range("B12")).Row
-
- For I = 12 To lastRow 'Range("A12").End(xlDown).Row
- If Cells(I, "B") <> "" Then
- Cells(I, "F").Value = "D," & Cells(I, "A").Value + 1 & ",1"
- Cells(I, "G").Value = "D," & Cells(I, "A").Value + 1 & ",2"
- Cells(I, "H").Value = "D," & Cells(I, "A").Value + 1 & ",3"
- Cells(I, "I").Value = "D," & Cells(I, "A").Value + 1 & ",4"
- Cells(I, "J").Value = "D," & Cells(I, "A").Value + 1 & ",5"
- Else
- End If
- Next
-
- For I = 47 To Range("A47").End(xlDown).Row
- If Cells(I, "B") <> "" Then
- If Cells(I, "B") <> "" Then
- Cells(I, "F").Value = "D," & Cells(I, "A").Value + 1 & ",1"
- Cells(I, "G").Value = "D," & Cells(I, "A").Value + 1 & ",2"
- Cells(I, "H").Value = "D," & Cells(I, "A").Value + 1 & ",3"
- Cells(I, "I").Value = "D," & Cells(I, "A").Value + 1 & ",4"
- Cells(I, "J").Value = "D," & Cells(I, "A").Value + 1 & ",5"
- Else
- End If
- End If
- Next
-
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- Range("A11").Select
-
- Dim xlFolder As String
- xlFolder = ThisWorkbook.Path & "\" & "i-Link 路徑檔" '指定資料夾
- If Dir(xlFolder, vbDirectory) = "" Then MkDir xlFolder
- Dim xPath As String
- xPath = Application.ActiveWorkbook.Path
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Titlename = ThisWorkbook.Sheets("製程檢查記錄表").Range("H4").Value
- With ActiveSheet
- .Copy
- ActiveSheet.DrawingObjects.Delete
- X = InputBox("請輸入檔名!!", "另存新檔", Titlename & " " & "製程(路徑檔)")
- If X <> "" Then
- Application.ActiveWorkbook.SaveAs Filename:=xlFolder & "\" & X, _
- FileFormat:=xlExcel8
- MsgBox "儲存成功!"
- ElseIf X = "" Then
- MsgBox "已取消儲存!!!"
- End If
- Application.ErrorCheckingOptions.BackgroundChecking = False
- Application.ActiveWorkbook.Close False
- End With
-
- For I = 11 To Range("B11").End(xlDown).Row
- If Cells(I, "A") <> "" Then
- Cells(I, "F").Value = ""
- Cells(I, "G").Value = ""
- Cells(I, "H").Value = ""
- Cells(I, "I").Value = ""
- Cells(I, "J").Value = ""
- ElseIf Cells(I, "A") = "" Then
- Exit For
- End If
- Next
- For I = 47 To Range("A47").End(xlDown).Row
- If Cells(I, "A") <> "" Then
- Cells(I, "F").Value = ""
- Cells(I, "J").Value = ""
- Cells(I, "H").Value = ""
- Cells(I, "I").Value = ""
- Cells(I, "J").Value = ""
- ElseIf Cells(I, "A") = "" Then
- Exit For
- End If
- Next
-
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
-
-
- End Sub
複製代碼
test2.rar (40.14 KB)
|