用户表单初始化
在我的Userform初始化中,我默认设置了optionbutton1和optionbutton4的值为true。 有四个选项button。 如果用户单击任何其他选项button,我想要以下是图表标题。
我已经调用了有关命令button的子过程:
Sub ChartName() If UserForm1.OptionButton1.value = True And UserForm1.OptionButton3.value = True Then ActiveChart.ChartTitle.Text = "First Case" ElseIf UserForm1.OptionButton2.value = True And UserForm1.OptionButton3.value = True Then ActiveChart.ChartTitle.Text = "Second Case" ElseIf UserForm1.OptionButton1.value = True And UserForm1.OptionButton4.value = True Then ActiveChart.ChartTitle.Text = "Third Case" ElseIf UserForm1.OptionButton2.value = True And UserForm1.OptionButton4.value = True Then ActiveChart.ChartTitle.Text = "Fourth Case" End Sub
但是,无论用户select什么,默认的optionbutton1和optionbutton3都被视为true,因此总是显示“First Case”。
有人可以告诉我如何解决这个问题吗?
不像我所希望的那样了解你的情况。 尝试这个:
Sub ChartName() If UserForm1.OptionButton1.Value = True And UserForm1.OptionButton3.Value = True Then ActiveChart.ChartTitle.Text = "First Case" Exit Sub End If If UserForm1.OptionButton2.Value = True And UserForm1.OptionButton3.Value = True Then ActiveChart.ChartTitle.Text = "Second Case" Exit Sub End If If UserForm1.OptionButton1.Value = True And UserForm1.OptionButton4.Value = True Then ActiveChart.ChartTitle.Text = "Third Case" Exit Sub End If If UserForm1.OptionButton2.Value = True And UserForm1.OptionButton4.Value = True Then ActiveChart.ChartTitle.Text = "Fourth Case" Exit Sub End If End Sub