Mình rất gà trong vba nên có record macro thế này:
Sub Intudong()
'
' Intudong Macro
' In tu dong tu 62 den 69
'
' Keyboard Shortcut: Ctrl+Shift+I
'
ActiveCell.FormulaR1C1 = "GEN-2014007-0062"
Range("M4").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:54").Select
Rows("10:54").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-48
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0063"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-45
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0064"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
ActiveWindow.ScrollRow = 1
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0065"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
ActiveWindow.SmallScroll Down:=-21
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
ActiveWindow.SmallScroll Down:=-24
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0066"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-27
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0067"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.ScrollRow = 1
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0068"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
ActiveWindow.SmallScroll Down:=-48
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-9
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0069"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
ActiveWindow.SmallScroll Down:=-42
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub
Nhờ các bác rút gọn công thức giúp. Nếu được thì tạo giúp mình thiết kế form sao cho nhập số chứng từ từ số a đến số b thì nó sẽ tự động truy xuất dữ liệu và in. Cảm ơn nhiều.
Sub Intudong()
'
' Intudong Macro
' In tu dong tu 62 den 69
'
' Keyboard Shortcut: Ctrl+Shift+I
'
ActiveCell.FormulaR1C1 = "GEN-2014007-0062"
Range("M4").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:54").Select
Rows("10:54").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-48
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0063"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-45
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0064"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
ActiveWindow.ScrollRow = 1
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0065"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
ActiveWindow.SmallScroll Down:=-21
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
ActiveWindow.SmallScroll Down:=-24
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0066"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-27
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0067"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
Rows("10:42").EntireRow.AutoFit
ActiveWindow.ScrollRow = 1
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0068"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
ActiveWindow.SmallScroll Down:=-48
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SmallScroll Down:=-9
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Range("L4").Select
ActiveCell.FormulaR1C1 = "GEN-2014007-0069"
Range("G3:H3").Select
Application.Run "'Mau In Phieu Khac moi.xltm'!Update"
Rows("10:42").Select
ActiveWindow.SmallScroll Down:=-42
Rows("10:42").EntireRow.AutoFit
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub
Nhờ các bác rút gọn công thức giúp. Nếu được thì tạo giúp mình thiết kế form sao cho nhập số chứng từ từ số a đến số b thì nó sẽ tự động truy xuất dữ liệu và in. Cảm ơn nhiều.



