首页 > 解决方案 > 仅在满足条件时才选中所有复选框

问题描述

我有一个 VBA 代码可以选中/取消选中所有复选框。但是,我希望代码仅选中/取消选中 E5:E150 列中没有“False”的复选框。

任何帮助将不胜感激,这是我的代码:

Sub SelectAllSubSector()

    Dim cBoxSector As CheckBox

    For Each cBoxSector In Worksheets("Input attractivite").CheckBoxes
        If Not Intersect(cBoxSector.TopLeftCell, Range("C5:C150")) Is Nothing Then
            If cBoxSector.Name <> ActiveSheet.CheckBoxes("Check Box 3").Name Then
                cBoxSector.Value = ActiveSheet.CheckBoxes("Check Box 3").Value
            End If
        End If
    Next cBoxSector

End Sub

标签: excelvbacheckbox

解决方案


推荐阅读