Rút gọn công thức (1 người xem)

Người dùng đang xem chủ đề này

sangatax

Thành viên mới
Tham gia
23/10/07
Bài viết
2
Được thích
0
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.
 
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.
Nhìn code mà giúp được bạn có lẽ chỉ có supper Man thôi !
Up 1 file lên rồi miêu tả công việc nội dung bạn cần giúp đỡ <--- chỉ đơn giản vậy thôi
 
Upvote 0
Nhìn dòng đầu tiên là thấy trớt quớt rồi.
Mã:
[COLOR=#ff0000]ActiveCell.FormulaR1C1[/COLOR] = "GEN-2014007-0062"
 
Upvote 0
Đây là file truy xuất dữ liệu từ phần mềm kế toán, mình muốn thiết kế form sao cho in được nhiều chứng từ cùng lúc. Nhờ các bác giúp. Cảm ơn
 

File đính kèm

Upvote 0

Bài viết mới nhất

Back
Top Bottom