Private Sub Worksheet_Change(ByVal Target As Range)
Dim DataRng As Range
Application.EnableEvents = False
If Not Intersect(Range("B8:E1000"), Target) Is Nothing Then
Set DataRng = Intersect(Target.EntireRow, Range("B8:E1000"))
With Intersect(Target.EntireRow, Range("F:F"))
.Offset(, 0).Value = "=RC[-4]*RC[-3]*RC[-2]*RC[-1]/1000000000"
.Offset(, 1).Value = "=RC[-6]*RC[-5]*RC[-4]*RC[-3]"
End With
On Error Resume Next
'[Đặt Msgbox và xoá số kiện thừa]
With Range("A7:G1000").Resize(, 1).SpecialCells(4)
If Not Intersect(.EntireRow, Target) Is Nothing _
And WorksheetFunction.CountA(Target) <> 0 Then
MsgBox "Nhap lieu thieu!", vbCritical, "Thong bao :"
Intersect(Target, .Cells.EntireRow).Cells(1).Offset(, -1).Select
End If
Intersect(.EntireRow, [A7:G1000].Cells).ClearContents
End With
Range("A" & WorksheetFunction.Max([B65536].End(xlUp).Row, [C65536].End(xlUp).Row, _
[D65536].End(xlUp).Row, [E65536].End(xlUp).Row) + 1, "A1000").ClearContents
'[/Đặt Msgbox và xoá số kiện thừa]
If DataRng.Columns.Count = 4 Then
On Error GoTo Tiep
If DataRng.SpecialCells(4).Count = DataRng.Count Then _
Intersect(DataRng.EntireRow, Range("A:G")).ClearContents
Tiep:
End If
End If
Application.EnableEvents = True
End Sub