代码放在工作表的change事件中:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then
If Cells(Target.Row, 1) = "事件A" Then
If (Target.Cells <> "循环") And (Target.Cells <> "无类型") Then
MsgBox "请重新输入"
End If
End If
If Cells(Target.Row, 1) = "事件B" Then
If (Target.Cells <> "周期") And (Target.Cells <> "无类型") Then
MsgBox "请重新输入"
End If
End If
If Cells(Target.Row, 1) = "事件C" Then
If (Target.Cells <> "时间") And (Target.Cells <> "无类型") Then
MsgBox "请重新输入"
End If
End If
End If
End Sub