Sub LuuDuLieu()
'Kiem tra xem co du lieu de luu hay khong?
If Sheets("Xuat").Range("StartRow") = "" Or IsNull(Sheets("Xuat").Range("StartRow")) Then
MsgBox "Khong co du lieu de luu!Vui long kiem tra lai!", , "Canh bao!"
Exit Sub
Else "Bắt đầu copy
Dim MaxDataRow, StartRow, EndRow, Zi, Zj As Integer
MaxDataRow = Sheets("Data").[A65000].End(xlUp).Row + 1
StartRow = Sheets("Xuat").Range("StartRow")
EndRow = Sheets("Xuat").Range("EndRow")
Zj = 0
For Zi = StartRow To EndRow
With Sheets("Data")
.Cells(MaxDataRow + Zj, 1) = Sheets("Xuat").Cells(Zi + 8, 1)
.Cells(MaxDataRow + Zj, 2) = Sheets("Xuat").Range("LoaiCtu")
.Cells(MaxDataRow + Zj, 3) = Sheets("Xuat").[G5]
.Cells(MaxDataRow + Zj, 4) = Sheets("Xuat").[G6]
.Cells(MaxDataRow + Zj, 5) = Year(Sheets("Xuat").[G6]) & Right("00" & Month(Sheets("Xuat").[G6]), 2)
.Cells(MaxDataRow + Zj, 6) = Sheets("Xuat").Range("TenNVBH")
.Cells(MaxDataRow + Zj, 7) = Sheets("Xuat").Range("MaKhach")
.Cells(MaxDataRow + Zj, 8) = Sheets("Xuat").Range("TenKhach")
.Cells(MaxDataRow + Zj, 9) = Sheets("Xuat").Range("DiaChi")
.Cells(MaxDataRow + Zj, 10) = Sheets("Xuat").Range("DienThoai")
.Cells(MaxDataRow + Zj, 11) = Sheets("Xuat").Cells(Zi + 8, 2)
.Cells(MaxDataRow + Zj, 12) = Sheets("Xuat").Cells(Zi + 8, 3)
.Cells(MaxDataRow + Zj, 13) = Sheets("Xuat").Cells(Zi + 8, 4)
.Cells(MaxDataRow + Zj, 14) = Sheets("Xuat").Cells(Zi + 8, 5)
.Cells(MaxDataRow + Zj, 15) = Sheets("Xuat").Cells(Zi + 8, 6)
.Cells(MaxDataRow + Zj, 16) = Sheets("Xuat").Cells(Zi + 8, 7)
.Cells(MaxDataRow + Zj, 17) = Sheets("Xuat").Range("ChietKhau") * Sheets("Xuat").Cells(Zi + 8, 7)
.Cells(MaxDataRow + Zj, 18) = Sheets("Xuat").Cells(Zi + 8, 7) * (1 - Sheets("Xuat").Range("ChietKhau"))
End With
Zj = Zj + 1
Next Zi
"=======================================================================================
"Tăng số chứng từ lên:
Call TangSoCtu
"=======================================================================================
a = MsgBox("Du Lieu da duoc luu thang cong, ban co muon xoa de nhap moi khong?", vbYesNo, "Du lieu da duoc luu...")
If a = vbYes Then Call XoaDuLieu Else Exit Sub "Hỏi xem có muốn để lại dữ liệu trên phiếu để làm tiếp hay xóa hết!?
"=======================================================================================
End If