ต้องการความช่วยเหลือในการโค๊ด
Posted: Wed Oct 29, 2014 1:15 pm
สวัสดีครับสมาชิกทกท่าน
ผมมีปัญหาในการใช้ โค๊ดคือ ต้องการการให้ print ใบเสร็จ แต่พอโปรแกรมทำงานแรกเสร็จเหมือนจะย้อนกลับมาหา file หลักไม่ได้ โดยมันจะขึ้น error subscript out of range ไม่ทราบว่าควรแก้ไขอย่างไรครับ โดยได้แนบโค๊ดมาด้วยครับ
ขอบคุณครับ
เอก
ผมมีปัญหาในการใช้ โค๊ดคือ ต้องการการให้ print ใบเสร็จ แต่พอโปรแกรมทำงานแรกเสร็จเหมือนจะย้อนกลับมาหา file หลักไม่ได้ โดยมันจะขึ้น error subscript out of range ไม่ทราบว่าควรแก้ไขอย่างไรครับ โดยได้แนบโค๊ดมาด้วยครับ
Code: Select all
Sub Macro4E()
Rows("5:5").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("5:5").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("6:6").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("6:6").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("7:7").Select
Selection.Copy
Windows("RENT.XLS").Activate
Rows("17:17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("7:7").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Rows("17:17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("8:8").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("8:8").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
'Rows("21:21").Select
'Selection.Copy
' Windows("RENT.XLS").Activate
'Range("A17").Select
'ActiveSheet.Paste
'Application.CutCopyMode = False
'ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("9:9").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("9:9").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("10:10").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("10:10").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("11:11").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("11:11").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("11:12").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("11:12").Select
Selection.Copy
Windows("BILL13N.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("13:13").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("13:13").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("14:14").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("14:14").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("15:15").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("15:15").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("16:16").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("16:16").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("17:17").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("17:17").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("18:18").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("18:18").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("19:19").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("19:19").Select
Selection.Copy
Windows("BILL13.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("20:20").Select
Selection.Copy
Windows("RENT.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
'Windows("soi1307.xls").Activate
Windows("Program_Label for print label &newbill1311-57.xls").Activate
Rows("20:20").Select
Selection.Copy
Windows("BILL13N.XLS").Activate
Range("A17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End Subเอก