excel vba - 检查单选按钮是否被选中?
我正在尝试检查这些简单单选按钮组的值,但我的语法已关闭,有谁知道该怎么做改变? 注意:它们是 Excel 选项按钮而不是 ActiveX 按钮,并且不在用户窗体上。
If Worksheets("Input").Shapes("Option Button 3").Select.Value = xlOn Then
MsgBox "fir"
ElseIf Worksheets("Input").Shapes("Option Button 4").Select.Value = xlOn Then
MsgBox "sec"
Else
MsgBox "none" 'in case they were deleted off the sheet
End If
I'm trying to check the value of these simple radio button groups but my syntax is off, does anyone know what to change?
Note: they are Excel Option Buttons not ActiveX ones and they are not on a userform.
If Worksheets("Input").Shapes("Option Button 3").Select.Value = xlOn Then
MsgBox "fir"
ElseIf Worksheets("Input").Shapes("Option Button 4").Select.Value = xlOn Then
MsgBox "sec"
Else
MsgBox "none" 'in case they were deleted off the sheet
End If
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
Try this
我有类似的问题。为了解决这个问题,我决定使用带有此宏 VBA 代码的切换按钮来访问其值并相应地切换我的显示:
I had a similar problem. To solve it, I decided to use a toggle button with this macro VBA code to access its value and toggle my display accordingly to it: