thanhnam_0119;99436]Ai có thể giúp tạo from nhập liệu và in theo mẫu mình gửi với nhé
Mình đang sử dụng mẫu như trên. Gửi bạn xem thử
Code này được viết bởi Tigertiger
Sub intkp2()
Dim eRso As Long, FrTo, rFr0 As Long, rTo0 As Long
Dim tFr As Long, tTo As Long, pCo As Long
Dim iR As Long, jR As Long, inRa
Application.ScreenUpdating = False
Do
eRso = Sheet1.[B9].End(xlDown).Row
FrTo = InputBox("Print CODE THE FROM ... -TO....;NoCOPIES")
If FrTo = "" Then Exit Sub
tFr = Int(Val(Left(FrTo, InStr(1, FrTo, "-", vbTextCompare))))
tTo = Int(Val(Mid(FrTo, InStr(1, FrTo, "-", vbTextCompare) + 1, _
InStr(1, FrTo, ";", vbTextCompare) - InStr(1, FrTo, "-", vbTextCompare))))
pCo = Int(Val(Right(FrTo, Len(FrTo) - InStr(1, FrTo, ";", vbTextCompare))))
'MsgBox tFr & " " & tTo & " " & pCo
rFr0 = -1
For iR = 9 To eRso
If Int(Val(Sheet1.Range("B" & iR).Value)) = tFr Then
rFr0 = Sheet1.Range("B" & iR).Row
Exit For
End If
Next
rTo0 = -1
If rFr0 >= 1 Then
For jR = iR To eRso
If Int(Val(Sheet1.Range("B" & jR).Value)) = tTo Then
rTo0 = Sheet1.Range("B" & jR).Row
Exit For
End If
Next
End If
Loop While (rFr0 < 1) Or (rTo0 < 1) Or (rTo0 < rFr0) Or (pCo < 1)
inRa = MsgBox("Nhan Yes de in TRANG 2, Nhan No de xem qua (Preview), Nhan Cancel de huy lenh", vbYesNoCancel)
If inRa = vbCancel Then Exit Sub
Sheet2.Select
For iR = rTo0 To rFr0 Step -1
Range("C4").Value = Sheet1.Range("B" & iR).Value
If inRa = vbYes Then
ActiveSheet.PrintOut From:=2, To:=2, Copies:=pCo, Collate:=False
Else: ActiveSheet.PrintOut From:=2, To:=2, Copies:=pCo, Collate:=False, Preview:=True:: End If
Next
End Sub