Sub PhieuDiem1() ' IN 1 PHIEU Dim i, n1, n2 As Integer Sheet2.Activate n1 = InputBox("Bat dau in tu dong nao ?") n2 = InputBox("Dong cuoi cung can in la dong nao ?") i = n1 While Sheet1.Cells(i, 1) "" Sheet2.Cells(5, 6) = Sheet1.Cells(i, 1) Sheet2.PrintOut Preview:=False If i = n2 Then Exit Sub i = i + 1 Wend End Sub Sub PhieuDiem2() ' IN 2 PHIEU Dim i, n1, n2 As Integer n1 = InputBox("Bat dau in tu dong nao ?") n2 = InputBox("Dong cuoi cung can in la dong nao ?" & Chr(13) & "Tong so dong in phai chan") Sheet3.Activate i = n1 While Sheet1.Cells(i, 1) "" Sheet3.Cells(5, 6) = Sheet1.Cells(i, 1) i = i + 1 Sheet3.Cells(26, 6) = Sheet1.Cells(i, 1) Sheet3.PrintOut Preview:=False If i = n2 Then Exit Sub i = i + 1 Wend End Sub
cảm ơn thầy rất nhiều, từ khi biết VBA làm việc nhẹ nhàng hẳn
Thầy ơi! Thầy ra video dạy lập trình bằng python đi thầy, con cám ơn thầy nhiều ah!!!
Sub PhieuDiem1() ' IN 1 PHIEU
Dim i, n1, n2 As Integer
Sheet2.Activate
n1 = InputBox("Bat dau in tu dong nao ?")
n2 = InputBox("Dong cuoi cung can in la dong nao ?")
i = n1
While Sheet1.Cells(i, 1) ""
Sheet2.Cells(5, 6) = Sheet1.Cells(i, 1)
Sheet2.PrintOut Preview:=False
If i = n2 Then Exit Sub
i = i + 1
Wend
End Sub
Sub PhieuDiem2() ' IN 2 PHIEU
Dim i, n1, n2 As Integer
n1 = InputBox("Bat dau in tu dong nao ?")
n2 = InputBox("Dong cuoi cung can in la dong nao ?" & Chr(13) & "Tong so dong in phai chan")
Sheet3.Activate
i = n1
While Sheet1.Cells(i, 1) ""
Sheet3.Cells(5, 6) = Sheet1.Cells(i, 1)
i = i + 1
Sheet3.Cells(26, 6) = Sheet1.Cells(i, 1)
Sheet3.PrintOut Preview:=False
If i = n2 Then Exit Sub
i = i + 1
Wend
End Sub