首页 > 解决方案 > vba中如何判断单选框是否被选中

问题描述

VBA中如何判断单选框是否被选中?表单控件,</p>

Set sht = ThisWorkbook.Sheets(1)
If sht.OptionButton1.Value = 1 Then
  MsgBox "ok!"
End If

不运行

标签: excelvba

解决方案


例子

Option Explicit

Public Sub Example()

    If ThisWorkbook.Sheets(1).OptionButtons("Option Button 1").Value > 0 Then
        MsgBox "Yes"
    Else
        MsgBox "No"
    End If

End Sub

推荐阅读