Excel中选中含有特定标志的checkbox
Sub SelectAllGroupsClick()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
ActiveSheet.Unprotect
Dim i
i = 0
For Each oCheck In ActiveSheet.CheckBoxes
i = InStr(1, oCheck.Name, "group", 1) '查找checkbox名称中含有“group”的位置。
If i = 1 Then
oCheck.Value = True
i = 0
End If
Next oCheck
Application.Calculation = xlCalculationAutomatic
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=True, AllowFiltering:=True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub