Private Sub btnin_Click()
Dim i As Long, j As Long, Khung As String, arrBB, arrBB2
Dim chk As Boolean
arrBB = Split(Range("K11"), ",")
For i = 0 To UBound(arrBB)
If InStr(1, arrBB(i), "-") = 0 Then
Range("K6").Value = arrBB(i)
Khung = WorksheetFunction.Index(Sheet7.Range("R2:R443"), WorksheetFunction.Match(CLng(arrBB(i)), Sheet7.Range("A2:A443"), 0), 1)
GoTo InBB
Else
arrBB2 = Split(arrBB(i), "-")
For j = CLng(arrBB2(0)) To CLng(arrBB2(1))
Range("K6").Value = j
Khung = WorksheetFunction.Index(Sheet7.Range("R2:R443"), WorksheetFunction.Match(j, Sheet7.Range("A2:A443"), 0), 1)
chk = True
GoTo InBB
VeJ: Next j
End If
InBB: Sheet2.Rows("17:17").EntireRow.AutoFit
Sheet2.PrintOut from:=txtP1.Text, To:=txtP2.Text, preview:=False
Sheet1.Rows("12:12").EntireRow.AutoFit
Sheet1.PrintOut from:=txtP1.Text, To:=txtP2.Text, preview:=False
Sheet8.Rows("12:12").EntireRow.AutoFit
Sheet8.PrintOut from:=txtP1.Text, To:=txtP2.Text, preview:=False
If Khung = "Khung nhom vach thach cao" Then
Sheet5.PrintOut from:=txtP1.Text, To:=txtP2.Text, preview:=False
ElseIf Khung = "Khung go vach thach cao" Then
Sheet6.PrintOut from:=txtP1.Text, To:=txtP2.Text, preview:=False
ElseIf Khung = "Khung sat" Then
Sheet4.PrintOut from:=txtP1.Text, To:=txtP2.Text, preview:=False
End If
If chk = True Then
chk = False
If j = CLng(arrBB2(1)) Then GoTo VeI Else: GoTo VeJ
End If
VeI: Next i
End Sub