Option Explicit
Sub [COLOR=#ff0000][B]InToanBo[/B][/COLOR]()
If MsgBox("Ban co chac in toan bo danh sach nay khong?", vbQuestion + vbYesNo, "Thông báo") = vbYes Then
Dim r As Long, sArray As Variant, Itm As Variant
Sheets("GiayMoi").Select
Call SpeedOn
With Sheets("DanhSach")
sArray = Range(.Range("B1"), .Range("B65536").End(xlUp))
For r = 1 To UBound(sArray)
Itm = sArray(r, 1)
If Trim(Itm) <> "" Then
[B6] = UCase(Itm) ' Neu chu lam sao de nhu vay thi bo ham UCase
ActiveWindow.SelectedSheets.PrintOut _
From:=1, _
To:=1, _
Copies:=1
End If
Next
End With
Call SpeedOff
End If
End Sub
Sub [COLOR=#ff0000][B]InTheoSTT[/B][/COLOR]()
Dim s As Long, e As Long
With Sheets("DanhSach")
s = Val(Trim(.Range("J1")))
e = Val(Trim(.Range("J2")))
If s = 0 Then
MsgBox "Ban phai nhap 'STT bat dau'"
.Range("J1").Select
Exit Sub
ElseIf e = 0 Then
MsgBox "Ban phai nhap 'STT ket thuc'"
.Range("J2").Select
Exit Sub
ElseIf s > e Then
MsgBox "Ban phai nhap 'STT bat dau' nho hon 'STT ket thuc'"
.Range("J1").Select
Exit Sub
End If
If MsgBox("Ban co chac in theo cac so thu tu da nhap?", vbQuestion + vbYesNo, "Thông báo") = vbYes Then
Sheets("GiayMoi").Select
Call SpeedOn
Dim r As Long, sArray As Variant, Itm As Variant
sArray = .Range("B" & s & ":B" & e)
If IsArray(sArray) Then
For r = 1 To UBound(sArray)
Itm = sArray(r, 1)
If Trim(Itm) <> "" Then
[B6] = UCase(Itm) ' Neu chu lam sao de nhu vay thi bo ham UCase
ActiveWindow.SelectedSheets.PrintOut _
From:=1, _
To:=1, _
Copies:=1
End If
Next
Else
[B6] = UCase(.Range("B" & s & ":B" & e))
ActiveWindow.SelectedSheets.PrintOut _
From:=1, _
To:=1, _
Copies:=1
End If
Call SpeedOff
End If
End With
End Sub