您好我不知道如何在excel 2010中创建一个复选框 激活 anothers复选框。
我的意思如果我选中第一个复选框,另一个复选框就是falso。
答案 0 :(得分:3)
这里有简短的例子。将名为MasterCheckBox的复选框添加到表单中。使用UserFormEnableEvents来抑制用户表单中的事件......如果需要。
Option Explicit
Private UserFormEnableEvents As Boolean
Private Sub UserForm_Initialize()
UserFormEnableEvents = True
End Sub
Private Sub MasterCheckBox_Change(): On Error GoTo Err_handler
Dim userFormControl As Control
UserFormEnableEvents = False
For Each userFormControl In Me.Controls
If (TypeOf userFormControl Is MSForms.CheckBox And _
userFormControl.Name <> MasterCheckBox.Name) Then
userFormControl.Value = Not userFormControl.Value
End If
Next
Err_handler:
If (Err.Number <> 0) Then MsgBox Err.Description
UserFormEnableEvents = True
End Sub