Bạn xem code và sửa giùm mình luôn nhé, mình sửa một hồi thấy sai tùm lum luôn
Sub SALES()
Dim NextRow As Long, i As Long
i = 0
NextRow = Sheets("XUAT").[A65536].End(xlUp).Row + 1
With Sheets("XUAT").Cells(NextRow, 1)
.Value = Val(frmnhaplieu.NM)
.Offset(, 0).Value = frmnhaplieu.NM
.Offset(, 2).Value = frmnhaplieu.MKH
.Offset(, 1).Value = frmnhaplieu.TKH
.Offset(, 4).Value = frmnhaplieu.cboMH
.Offset(, 3).Value = frmnhaplieu.TH
.Offset(, 5).Value = frmnhaplieu.QC
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG
.Offset(, 8).Value = frmnhaplieu.TT
.Offset(, 9).Value = frmnhaplieu.TGN
.Offset(, 10).Value = frmnhaplieu.TG
.Offset(, 11).Value = frmnhaplieu.NDK
.Offset(, 12).Value = frmnhaplieu.GC
'------------------------------------------------------------------------------------------
If Val(Replace(frmnhaplieu.SL1, ",", "")) > 0 Then
i = 1
.Offset(, 0).Value = frmnhaplieu.NM
.Offset(, 2).Value = frmnhaplieu.MKH
.Offset(, 1).Value = frmnhaplieu.TKH
.Offset(, 4).Value = frmnhaplieu.cboMH1
.Offset(, 3).Value = frmnhaplieu.TH1
.Offset(, 5).Value = frmnhaplieu.QC1
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL1, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG1
.Offset(, 8).Value = frmnhaplieu.TT1
.Offset(, 9).Value = frmnhaplieu.TGN1
'------------------------------------------------------------------------------------------
If Val(Replace(frmnhaplieu.SL2, ",", "")) > 0 Then
i = 2
.Offset(, 0).Value = frmnhaplieu.NM
.Offset(, 2).Value = frmnhaplieu.MKH
.Offset(, 1).Value = frmnhaplieu.TKH
.Offset(, 4).Value = frmnhaplieu.cboMH2
.Offset(, 3).Value = frmnhaplieu.TH2
.Offset(, 5).Value = frmnhaplieu.QC2
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL2, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG2
.Offset(, 8).Value = frmnhaplieu.TT2
.Offset(, 9).Value = frmnhaplieu.TGN2
'------------------------------------------------------------------------------------------
If Val(Replace(frmnhaplieu.SL3, ",", "")) > 0 Then
i = 3
.Offset(, 0).Value = frmnhaplieu.NM
.Offset(, 2).Value = frmnhaplieu.MKH
.Offset(, 1).Value = frmnhaplieu.TKH
.Offset(, 4).Value = frmnhaplieu.cboMH3
.Offset(, 3).Value = frmnhaplieu.TH3
.Offset(, 5).Value = frmnhaplieu.QC3
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL3, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG3
.Offset(, 8).Value = frmnhaplieu.TT3
.Offset(, 9).Value = frmnhaplieu.TGN3
'------------------------------------------------------------------------------------------
If Val(Replace(frmnhaplieu.SL4, ",", "")) > 0 Then
i = 4
.Offset(, 0).Value = frmnhaplieu.NM
.Offset(, 2).Value = frmnhaplieu.MKH
.Offset(, 1).Value = frmnhaplieu.TKH
.Offset(, 4).Value = frmnhaplieu.cboMH4
.Offset(, 3).Value = frmnhaplieu.TH4
.Offset(, 5).Value = frmnhaplieu.QC4
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL4, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG4
.Offset(, 8).Value = frmnhaplieu.TT4
.Offset(, 9).Value = frmnhaplieu.TGN4
'------------------------------------------------------------------------------------------
If Val(Replace(frmnhaplieu.SL5, ",", "")) > 0 Then
i = 5
.Offset(, 4).Value = frmnhaplieu.cboMH5
.Offset(, 3).Value = frmnhaplieu.TH5
.Offset(, 5).Value = frmnhaplieu.QC5
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL5, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG5
.Offset(, 8).Value = frmnhaplieu.TT5
.Offset(, 9).Value = frmnhaplieu.TGN5
'------------------------------------------------------------------------------------------
If Val(Replace(frmnhaplieu.SL6, ",", "")) > 0 Then
i = 6
.Offset(, 0).Value = frmnhaplieu.NM
.Offset(, 2).Value = frmnhaplieu.MKH
.Offset(, 1).Value = frmnhaplieu.TKH
.Offset(, 4).Value = frmnhaplieu.cboMH6
.Offset(, 3).Value = frmnhaplieu.TH6
.Offset(, 5).Value = frmnhaplieu.QC6
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL6, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG6
.Offset(, 8).Value = frmnhaplieu.TT6
.Offset(, 9).Value = frmnhaplieu.TGN6
'------------------------------------------------------------------------------------------
If Val(Replace(frmnhaplieu.SL7, ",", "")) > 0 Then
i = 7
.Offset(, 0).Value = frmnhaplieu.NM
.Offset(, 2).Value = frmnhaplieu.MKH
.Offset(, 1).Value = frmnhaplieu.TKH
.Offset(, 4).Value = frmnhaplieu.cboMH7
.Offset(, 3).Value = frmnhaplieu.TH7
.Offset(, 5).Value = frmnhaplieu.QC7
.Offset(, 6).Value = Val(Replace(frmnhaplieu.SL7, ",", ""))
.Offset(, 7).Value = frmnhaplieu.DG7
.Offset(, 8).Value = frmnhaplieu.TT7
.Offset(, 9).Value = frmnhaplieu.TGN7
End If
'------------------------------------------------------------------------------------------
a = MsgBox("cap nhat thanh cong!An OK de tiep tuc!", vbInformation + vbOKOnly, "Cap nhap du lieu thanh cong")
End Sub
Sub Refresh_frmNhapLieu()
'Xoa Tieu de:
frmnhaplieu.NM = ""
frmnhaplieu.MKH = ""
frmnhaplieu.TKH = ""
'-------------------------------
'Xoa chi tiet phieu:
frmnhaplieu.cboMH = ""
frmnhaplieu.TH = ""
frmnhaplieu.QC = ""
frmnhaplieu.SL = ""
frmnhaplieu.DG = ""
frmnhaplieu.TT = ""
frmnhaplieu.TGN = ""
frmnhaplieu.TG = ""
frmnhaplieu.NDK = ""
frmnhaplieu.GC = ""
'-------------------------------
frmnhaplieu.cboMH1 = ""
frmnhaplieu.TH1 = ""
frmnhaplieu.QC1 = ""
frmnhaplieu.SL1 = ""
frmnhaplieu.DG1 = ""
frmnhaplieu.TT1 = ""
'-------------------------------
frmnhaplieu.cboMH2 = ""
frmnhaplieu.TH2 = ""
frmnhaplieu.QC2 = ""
frmnhaplieu.SL2 = ""
frmnhaplieu.DG2 = ""
frmnhaplieu.TT2 = ""
'-------------------------------
frmnhaplieu.cboMH3 = ""
frmnhaplieu.TH3 = ""
frmnhaplieu.QC3 = ""
frmnhaplieu.SL3 = ""
frmnhaplieu.DG3 = ""
frmnhaplieu.TT3 = ""
'-------------------------------
frmnhaplieu.cboMH4 = ""
frmnhaplieu.TH4 = ""
frmnhaplieu.QC4 = ""
frmnhaplieu.SL4 = ""
frmnhaplieu.DG4 = ""
frmnhaplieu.TT4 = ""
'-------------------------------
frmnhaplieu.cboMH5 = ""
frmnhaplieu.TH5 = ""
frmnhaplieu.QC5 = ""
frmnhaplieu.SL5 = ""
frmnhaplieu.DG5 = ""
frmnhaplieu.TT5 = ""
'-------------------------------
frmnhaplieu.cboMH6 = ""
frmnhaplieu.TH6 = ""
frmnhaplieu.QC6 = ""
frmnhaplieu.SL6 = ""
frmnhaplieu.DG6 = ""
frmnhaplieu.TT6 = ""
'-------------------------------
frmnhaplieu.cboMH7 = ""
frmnhaplieu.TH7 = ""
frmnhaplieu.QC7 = ""
frmnhaplieu.SL7 = ""
frmnhaplieu.DG7 = ""
frmnhaplieu.TT7 = ""
End Sub