Sub RoundedRectangle1_Click()
Dim sArr(), eRow&, fRow&, sRow&, i&, strRes$
With Sheets("Ten")
eRow = .Range("B" & Rows.Count).End(xlUp).Row
If eRow < 5 Then MsgBox ("Khong co du lieu"): Exit Sub
sArr = .Range("C6:C" & eRow).Value
End With
sRow = UBound(sArr)
On Error Resume Next
fRow = Range("B2").Value
If fRow < 1 Then fRow = 1
eRow = Range("C2").Value
If eRow > sRow Then eRow = sRow
For i = fRow To eRow
Range("G3").Value = sArr(i, 1)
Range("E1:J16").PrintPreview ' Xem truoc khi in
'Range("E1:J16").PrintOut 'In
strRes = strRes & "," & i
Next i
If Len(strRes) Then
MsgBox ("Da in cac So thu tu: " & Mid(strRes, 2, Len(strRes)))
Else
MsgBox ("Du lieu So Thu Tu khong phu hop, Khong In")
End If
End Sub
Sub RoundedRectangle2_Click()
Dim sArr(), S, eRow&, N, sRow&, i&, ik&, strRes$
With Sheets("Ten")
eRow = .Range("B" & Rows.Count).End(xlUp).Row
If eRow < 5 Then MsgBox ("Khong co du lieu"): Exit Sub
sArr = .Range("C6:C" & eRow).Value
End With
sRow = UBound(sArr)
On Error Resume Next
strRes = Range("B4").Value
S = Split("," & strRes, ",")
strRes = ""
N = UBound(S)
For i = 1 To N
If IsNumeric(S(i)) Then
ik = CLng(S(i))
If ik > 0 And ik <= sRow Then
Range("G3").Value = sArr(ik, 1)
Range("E1:J16").PrintPreview ' Xem truoc khi in
'Range("E1:J16").PrintOut 'In
strRes = strRes & "," & ik
End If
End If
Next i
If Len(strRes) Then
MsgBox ("Da in cac So thu tu: " & Mid(strRes, 2, Len(strRes)))
Else
MsgBox ("Du lieu So Thu Tu khong phu hop, Khong In")
End If
End Sub