Sub Worksheet_Change(ByVal cell As Range)
On Error Resume Next
Dim TBinh As String 'Kich thuoc trung binh '
Dim soTBinh As Double 'Chuyen so kich thuoc trung binh'
Dim sodsdccong As Double 'So dung sai dieu chinh cong'
Dim sodscong As Double 'So dung sai cong'
Dim DSDCCong As String 'dung sai dieu chinh cong'
Dim DSCong As String 'dung sai cong '
Dim Sodsdctru As Double 'So dung sai dieu chinh tru '
Dim SoDSTru As Double 'So dung sai tru '
Dim dsdctru As String 'Dung sai dieu chinh tru '
Dim DSTru As String 'Dung sai tru '
Dim sonhaplieu As Double 'So nhap lieu '
Dim nhaplieu As String 'Nhap lieu '
Dim ktdccantren As Double 'Kich '
Dim ktcantren As Double 'Kich thuoc can tren = trung binh + dung sai cong '
Dim ktdccanduoi As Double, ktcanduoi As Double
Dim resultNG As String, resultOK As String
Dim beginrow As Range
TBinh = Cells(cell.Row, 3) 'ActiveCell.Column-main value '
If IsNumeric(TBinh) Then 'If is number_OK,other Not '
soTBinh = CDbl(TBinh)
DSDCCong = Cells(cell.Row, 6) 'ActiveCell.Column '
DSCong = Cells(cell.Row, 4) 'ActiveCell.Column '
dsdctru = Cells(cell.Row, 7) 'ActiveCell.Column '
DSTru = Cells(cell.Row, 5) 'ActiveCell.Column '
End If
nhaplieu = Cells(cell.Row, cell.Column)
If IsNumeric(TBinh) And IsNumeric(nhaplieu) Then
sonhaplieu = CDbl(nhaplieu)
If IsNumeric(DSDCCong) And IsNumeric(DSCong) Then
sodsdccong = CDbl(DSDCCong)
sodscong = CDbl(DSCong)
ktdccantren = soTBinh + sodsdccong
ktcantren = soTBinh + sodscong
ktdccantren = Application.Round(ktdccantren, 10)
ktcantren = Application.Round(ktcantren, 10)
sonhaplieu = Application.Round(sonhaplieu, 10)
If IsNumeric(dsdctru) And IsNumeric(DSTru) Then
Sodsdctru = CDbl(dsdctru)
SoDSTru = CDbl(DSTru)
ktdccanduoi = soTBinh + Sodsdctru
ktcanduoi = soTBinh + SoDSTru
ktdccanduoi = Application.Round(ktdccanduoi, 10)
ktcanduoi = Application.Round(ktcanduoi, 10)
sonhaplieu = Application.Round(sonhaplieu, 10)
If sonhaplieu >= ktdccanduoi And sonhaplieu <= ktdccantren Then
'clor = clorOK '
cell.Interior.ColorIndex = 4
End If
If sonhaplieu > ktdccantren And sonhaplieu <= ktcantren Then
'clor = clorADJ '
cell.Interior.ColorIndex = 6
End If
If sonhaplieu < ktdccanduoi And sonhaplieu >= ktcanduoi Then
'clor = clorADJ '
cell.Interior.ColorIndex = 6
End If
If sonhaplieu > ktcantren Or sonhaplieu < ktcanduoi Then
'clor = clorNG '
cell.Interior.ColorIndex = 3
End If
End If
End If
End If
'.. . . . . . . . '
End Sub