Private Sub Worksheet_Change(ByVal Target As Range)
Dim r&, t$, c
With Target
If .Count > 1 Or .Row < 12 Then Exit Sub Else r = .Row
If Application.Mode(Array(.Column, 7, 18, 20, 21, 0, 0)) = 0 Then Exit Sub
End With
On Error GoTo 1
Application.EnableEvents = False
If Cells(r, "G") = "" Then Cells(r, "V").Resize(1, 3) = "": GoTo 1
Cells(r, "V") = Cells(r, "R") + Cells(r, "T") + Cells(r, "U")
Cells(r, "W") = Cells(r, "G") - Cells(r, "V")
If Cells(r, "W") = 0 Then t = "結": c = 41
If Cells(r, "V") > Cells(r, "G") Then t = "資料錯誤": c = 0
Cells(r, "X") = t
Cells(r, "X").Font.ColorIndex = c
1: Application.EnableEvents = True
End Sub