【问题标题】:VBA + checkboxes + autofilterVBA + 复选框 + 自动过滤器
【发布时间】:2012-10-18 00:54:19
【问题描述】:

我在 excel 中有一个带有自动过滤器的列表,其中每一行都有一个复选框。

我制作了一个带有宏的按钮来选择所有复选框。这工作正常。但是当我过滤我的行时,我的“全选”必须只选择可见的复选框

使用我的代码,它仍然会选中所有复选框。有人有解决这个问题的想法吗?

我的代码:

  Sub SelectAll()
  Dim chk As CheckBox

  If Worksheets("Summary").FilterMode = True Then
    MsgBox "Filter mode is on"      
  Else
    MsgBox "Filter mode is off"
    For Each chk In Worksheets("Summary").CheckBoxes
      chk.Value = Checked
    Next
  End If
End Sub

提前致谢

【问题讨论】:

    标签: excel vba autofilter


    【解决方案1】:

    我认为您的复选框被过滤器隐藏了。

    这可能会在您的循环中有所帮助:

    Dim chkRng As Range
    Set chkRng = chk.TopLeftCell
    Let addr = chkRng.Address ' for debugging to verify the cell the checkbox is associated with
    Dim visr As Range
    Set visr = chkRng.SpecialCells(xlCellTypeVisible)
    Set ans = Intersect(visr, chkRng)
    If Not ans Is Nothing Then
       MsgBox ("visible")
    End If
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-29
      • 2014-03-30
      • 1970-01-01
      • 2021-07-18
      • 2014-07-21
      • 2011-10-25
      相关资源
      最近更新 更多