VBA中按钮问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 16:19:30
我用VBA做了个调查表,现在就是想实现如下功能:有的选项选择是,然后才可以接着选择对应的下面的内容,如果选择否,则希望下面的选项为不可选,防止误操作。
If OptionButton1.Value = True Then
Cells(iRow, 1) = Me.OptionButton1.Caption And CheckBox1.Enabled = False And CheckBox2.Enabled = False And CheckBox3.Enabled = False And CheckBox4.Enabled = False

我这样写代码不知道行不行?

And语句是用于逻辑判断中的。你需要把那些去掉。可以这样写:
If OptionButton1.Value = True Then
Cells(iRow, 1) = Me.OptionButton1.Caption
CheckBox1.Enabled = False
CheckBox2.Enabled = False
CheckBox3.Enabled = False
CheckBox4.Enabled = False
End If