复选框选中后弹出窗口显示两次

时间:2015-06-23 19:47:41

标签: excel vba excel-vba

我目前已将其设置为无法同时检查两个复选框,如果是,则会弹出错误并再次取消选中该复选框。但是目前它正在弹出两次消息。如何解决这个问题?

Private Sub CheckBox1_Click()
If CheckBox2.Value = True Then
MsgBox "Must be sent separate."
CheckBox1.Value = False
End If
End Sub

1 个答案:

答案 0 :(得分:1)

我认为您只需要更改它:原因是它在切换checkbox1时运行检查

Private Sub CheckBox1_Click()
If CheckBox2.Value = True And CheckBox1.Value = True Then
MsgBox "Must be sent separate."
CheckBox1.Value = False
End If
End Sub