【发布时间】:2015-08-06 20:10:38
【问题描述】:
所以我正在尝试制作一个用户窗体,如果两个复选框都被标记,则将允许单击该按钮。我尝试了一堆不同的代码,这是我的第一次尝试。
Private Sub CommandButton1_Click()
If CheckBox1.Value = True & CheckBox2.Value = True Then
CommandButton1.Enabled = True
Call GOGOGO
ElseIf CheckBox1.Value = True & CheckBox2.Value = False Then
MsgBox ("Run Characteristics Version 1.2.xlsm")
ElseIf CheckBox1.Value = False & CheckBox2.Value = True Then
MsgBox ("Log in")
Else
MsgBox ("Log in and Run Characteristics Version 1.2.xlsm")
End If
End Sub
也试过了
Private Sub CheckBox1_Change()
'Evaluate the value of the CheckBox
Select Case CheckBox1.Value
Case True, False
End Select
End Sub
Private Sub CheckBox2_Change()
'Evaluate the value of the CheckBox
Select Case CheckBox2.Value
Case True, False
End Select
End Sub
Private Sub CommandButton1_Click()
Select Case CheckBox1.Value
Select Case CheckBox2.Value
If CheckBox1.Value = True & CheckBox2.Value = True Then
CommandButton1.Enabled = True
Call GOGOGO
ElseIf CheckBox1.Value = True & CheckBox2.Value = False Then
MsgBox ("Run Characteristics Version 1.2.xlsm")
ElseIf CheckBox1.Value = False & CheckBox2.Value = True Then
MsgBox ("Log in")
Else
MsgBox ("Log in and Run Characteristics Version 1.2.xlsm")
End If
End Select
End Select
End Sub
两者都只给了我我的第一个 ElseIf。因此,当我单击命令按钮时,使用所有不同的复选框组合,我总是得到 msgBox "Run Characteristics...."
问题:如何在 Excel 用户窗体中创建一个按钮,仅在标记 2 个复选框时运行命令?
【问题讨论】: