Hà Quang Dương
Thành viên mới

- Tham gia
- 26/7/15
- Bài viết
- 12
- Được thích
- 2
Dear các Anh / Chị
Cac anh chi vui long sua code giup em ah.
1. Noi dug : VBA in hang loat
2.Van de : Muon I sheet 1 theo so thu tu cua sheet 2
Em xin cam on
Private Sub CommandButton1_Click()
Dim Tuso, Denso, I, J As Long
Dim Sh As Worksheet, Rng As Range, sRng As Range
If IsNumeric(TextBox1) = False Then
MsgBox "Tu so phai là kieu so"
TextBox1.SetFocus
Exit Sub
End If
If IsNumeric(TextBox2) = False Then
MsgBox "Den so phai là kieu so"
TextBox2.SetFocus
Exit Sub
End If
If TextBox1 > TextBox2 Then
MsgBox "Tu so phai nho hon hoac bang Den so"
Exit Sub
End If
Tuso = TextBox1.Value
Denso = TextBox2.Value
UserForm1.Hide
For I = Tuso To Denso
Set Sh = Sheet2
Set Rng = Sh.Range(Sh.[A5], Sh.[A65536].End(xlUp))
Set sRng = Rng.Find(I, , xlFormulas, xlWhole)
If sRng Is Nothing Then
Else
Sheet1.PrintOut
End If
Next I
End Sub
Cac anh chi vui long sua code giup em ah.
1. Noi dug : VBA in hang loat
2.Van de : Muon I sheet 1 theo so thu tu cua sheet 2
Em xin cam on
Private Sub CommandButton1_Click()
Dim Tuso, Denso, I, J As Long
Dim Sh As Worksheet, Rng As Range, sRng As Range
If IsNumeric(TextBox1) = False Then
MsgBox "Tu so phai là kieu so"
TextBox1.SetFocus
Exit Sub
End If
If IsNumeric(TextBox2) = False Then
MsgBox "Den so phai là kieu so"
TextBox2.SetFocus
Exit Sub
End If
If TextBox1 > TextBox2 Then
MsgBox "Tu so phai nho hon hoac bang Den so"
Exit Sub
End If
Tuso = TextBox1.Value
Denso = TextBox2.Value
UserForm1.Hide
For I = Tuso To Denso
Set Sh = Sheet2
Set Rng = Sh.Range(Sh.[A5], Sh.[A65536].End(xlUp))
Set sRng = Rng.Find(I, , xlFormulas, xlWhole)
If sRng Is Nothing Then
Else
Sheet1.PrintOut
End If
Next I
End Sub