1. 程式人生 > >excel vba for 調配車間

excel vba for 調配車間

Sub SetA1()


'獲取使用者輸入的序列號列印範圍
mNumFrom = ThisWorkbook.Worksheets("Sheet1").Range("B1").Value
mNumTo = ThisWorkbook.Worksheets("Sheet1").Range("D1").Value




For r = mNumFrom To mNumTo Step 3


'將序列號填入對於位置
ThisWorkbook.Worksheets("Sheet1").Range("A2").Value = r
ThisWorkbook.Worksheets("Sheet1").Range("A3").Value = r + 1
ThisWorkbook.Worksheets("Sheet1").Range("A4").Value = r + 2


'設定列印區域
ActiveSheet.PageSetup.PrintArea = "$A$2:$E$5"


'執行列印
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
        
'延時一會兒
Application.Wait (Now + TimeValue("0:00:07"))


Next


End Sub