Giải thích dùm mình đoạn code sau;
(cho mình cám ơn trước nha)
Sub nhap_dulieu()
Dim n1, n2, n3, n4, n5, n6, n7, Shift As Integer
Dim Op, Pro_date, Line As String
'kiem tra loi
n1 = Application.WorksheetFunction.CountBlank(Sheets("inputdata").Range("F4:F18"))
n2 = Application.WorksheetFunction.CountBlank(Sheets("inputdata").Range("G4:G18"))
n3 = Application.WorksheetFunction.CountBlank(Sheets("inputdata").Range("H4:H18"))
n4 = Application.WorksheetFunction.CountBlank(Sheets("inputdata").Range("I4:I18"))
n5 = Application.WorksheetFunction.CountBlank(Sheets("inputdata").Range("J4:J18"))
n6 = Application.WorksheetFunction.CountBlank(Sheets("inputdata").Range("K4:K18"))
n7 = Application.WorksheetFunction.CountBlank(Sheets("inputdata").Range("L4:L18"))
Pro_date = Sheets("inputdata").Range("B2").Value
Shift = Sheets("inputdata").Range("D2").Value
Line = Sheets("inputdata").Range("F2").Value
Op = Sheets("inputdata").Range("H2").Value
' check cell
If Pro_date = "" Then
MsgBox ("BAN CHUA NHAP: Ngay San Xuat")
Exit Sub
End If
If Shift = 0 Then
MsgBox ("BAN CHUA NHAP: Ca San Xuat")
Exit Sub
End If
If Line = "" Then
MsgBox ("BAN CHUA NHAP: Line San Xuat")
Exit Sub
End If
If Op = "" Then
MsgBox ("BAN CHUA NHAP: TEN VHM ")
Exit Sub
End If
If n1 = 15 And n2 = 15 And n3 = 15 Then
MsgBox "BAN CHUA NHAP DATA VAO COT: F, G, H !!!"
Exit Sub
End If
If n1 = n7 And n2 = n7 And n3 = n7 And n4 = n7 And n5 = n7 And n6 = n7 Then
UserForm1.Show
Else
MsgBox "BAN KIEM TRA LAI DATA "
End If
End Sub
Sub Add_BOM(Posi As Integer)
Dim i, n, Dem As Integer
'Call Unpro_Form
'Clear material label, BOM, financle coefficien
Range("A23:I35").ClearContents
Range("P23
35").ClearContents
' Add label, BOM, Unit, financl coeffient
n = Application.WorksheetFunction.Subtotal(3, Sheets("Products").Range("L5:BH5"))
Dem = 23
For i = 12 To n + 11
If Sheets("Products").Cells(Posi, i).Value <> "" Then
Range("A" & Dem).Value = Sheets("Products").Cells(3, i).Value ' Add code
Range("B" & Dem).Value = Sheets("Products").Cells(5, i).Value ' Add Unit
Range("D" & Dem).Value = Sheets("Products").Cells(4, i).Value ' Add Unit
Range("E" & Dem).Value = Sheets("Products").Cells(Posi, i).Value ' Add BOM
Dem = Dem + 1
End If
Next
'Call Pro_Form
End Sub