简体   繁体   中英

VBA - For Each, OptionButtons and Groups

I'd like to unactivate my option buttons but since I've grouped them with altogether my code won't work anymore.

So far I have this :

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

it just skips the part "For each optBtn in...". I don't use activexControls.

My groups look like this :

在此处输入图片说明

在此处输入图片说明

I've already been helped but since I grouped my forms it does not work anymore :(. Thanks in advance for your help

The following code will deselect all options in group "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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM