こんにちは、Excel 2010 で別のチェック ボックスをアクティブにするチェック ボックスを作成する方法がわかりません。
つまり、最初のチェックボックスをオンにすると、他のチェックボックスも偽装されます。
ここで短い例。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