VBA – 对于每个选项button和组
我想取消激活我的选项button,但由于我已经把它们分组在一起,我的代码将不再工作。
到目前为止,我有这样的:
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
它只是跳过“对于每个optBtn in …”的部分。 我不使用activexControls。
我的小组看起来像这样:
我已经得到了帮助,但由于我分组我的forms,它不工作了:(先谢谢您的帮助
以下代码将取消select“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