gpt4 book ai didi

vba - 用户表单初始化

转载 作者:行者123 更新时间:2023-12-02 23:15:45 24 4
gpt4 key购买 nike

在我的用户表单初始化中,我已将 optionbutton1 和 optionbutton4 的值默认设置为 true。有四个选项按钮。如果用户单击任何其他选项按钮,我希望以下内容成为图表标题。

我已经调用了与命令按钮相关的子过程:

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

但是,无论用户选择什么,默认的 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

关于vba - 用户表单初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31919521/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com