这可能是一个愚蠢的问题,但答案很简单,但在用户表单方面我是一个真正的新手。
我的“Frame 3”有 5 个不同的选项按钮(Dest1、Dest2、Dest3、Dest4、Dest5) 选择选项后,所选选项的标题值存储在哪里?我如何使用 vba 访问它。
谢谢你, 乔什
最佳答案
这只是您可以使用的一些示例代码。将选项按钮添加到组中,然后您就可以从那里开始。我使用了组,因为您有多个框架,您可以根据组进行检查,并且有多个组,然后检查为每个组选择了哪个。
Private Sub CommandButton1_Click()
Dim x As Control
' Loop through ALL the controls on the UserForm.
For Each x In Me.Controls
' Check to see if "Option" is in the Name of each control.
If InStr(x.Name, "Option") Then
' Check Group name.
If x.GroupName = "Grp1" Then
' Check the status of the OptionButton.
If x.Value = True Then
MsgBox x.Caption
Exit For
End If
End If
End If
Next
End Sub
关于vba - Excel - 返回所选选项按钮的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21434156/