VBA - 对于每个选项按钮和组
VBA - For Each, OptionButtons and Groups
我想取消激活我的选项按钮,但由于我已经将它们组合在一起,所以我的代码将不再有效。
到目前为止我有这个:
Sub Clean_sheet()
Dim Ws as Worksheet
Dim optBtn As OptionButton
Dim m As Byte
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Set Ws = ThisWorkbook.Sheets("Externe")
For Each optBtn In Ws.OptionButtons
optBtn.Value = -4146
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
它只是跳过了 "For each optBtn in..." 部分。我不使用 activexControls。
我的群组是这样的:
但自从我将表格分组后,它就不再起作用了:(。
预先感谢您的帮助
以下代码将取消选择组 "GPE_M1" 中的所有选项:
Dim Group_Frame As Shape
Dim Group_Item As Shape
Set Group_Frame = ws.Shapes("GPE_M1") 'top frame
For Each Group_Item In Group_Frame.GroupItems
If Group_Item.FormControlType = xlOptionButton Then
Group_Item.ControlFormat.Value = -4146
End if
Next Group_Item
我想取消激活我的选项按钮,但由于我已经将它们组合在一起,所以我的代码将不再有效。
到目前为止我有这个:
Sub Clean_sheet()
Dim Ws as Worksheet
Dim optBtn As OptionButton
Dim m As Byte
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Set Ws = ThisWorkbook.Sheets("Externe")
For Each optBtn In Ws.OptionButtons
optBtn.Value = -4146
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
它只是跳过了 "For each optBtn in..." 部分。我不使用 activexControls。
我的群组是这样的:
以下代码将取消选择组 "GPE_M1" 中的所有选项:
Dim Group_Frame As Shape
Dim Group_Item As Shape
Set Group_Frame = ws.Shapes("GPE_M1") 'top frame
For Each Group_Item In Group_Frame.GroupItems
If Group_Item.FormControlType = xlOptionButton Then
Group_Item.ControlFormat.Value = -4146
End if
Next Group_Item