Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [G4].Resize(9)) Is Nothing Then
Dim Hai As String, Ba As String
[P3:P6].Value = ""
If Target.Offset(, -2).Value = "" And Target.Value <> "" Then
Hai = "M"
ElseIf Target.Offset(, -2).Value <> "" And Target.Value = "" Then
Hai = "C": Ba = "TB"
ElseIf Target.Value = Target.Offset(, -2).Value Then
Hai = "N": Ba = "TDL"
ElseIf Target.Value <> Target.Offset(, -2).Value Then
Hai = "T"
End If
[p2].Value = Hai: [p3].Value = Ba
End If
End Sub