Private Sub Worksheet_Change(ByVal Target As Range)
'----------------------------------------------------------------
Application.EnableEvents = False
If Target.Column = 5 And Target.Row > 4 Then ' co tac dung voi cot thu 5, dong lon hon 4
Set DGiai = Target
If InStr(DGiai, ":") Then
Bthuc = Right(DGiai, Len(DGiai) - InStr(DGiai, ":"))
Bthuc = Replace(Trim(Bthuc), " ", "")
If Bthuc = "" Then GoTo Thoat
ElseIf Val(Trim(DGiai)) <> 0 Or Left(Trim(DGiai), 1) = "(" Or Left(Trim(DGiai), 2) = "0." Or Left(Trim(DGiai), 2) = "0," Then
Bthuc = Replace(Trim(DGiai), " ", "")
Else: GoTo Thoat
End If
Bthuc = Replace(Bthuc, ",", ".")
Bthuc = Replace(Bthuc, "=", "")
On Error GoTo Coloi
Target.Offset(0, 1) = "=" & Trim(Bthuc)
If Target.Interior.ColorIndex = 19 Then Target.Interior.ColorIndex = xlNone
GoTo Thoat
Coloi:
Target.Interior.ColorIndex = 19
End If
Thoat:
Set DGiai = Nothing
Application.EnableEvents = True
'----------------------------------------------------------------
End Sub