vba 自动筛选具有空白背景颜色但有数据的单元格

问题描述 投票:0回答:1

如何自动过滤具有空白背景颜色但有数据的单元格?

我需要传入 colorIndex 什么值才能得到以下结果?

在此输入图片描述

Sub FilterByColor()
    Dim rng As Range
    Dim cell As Range
    Dim colorIndex As Long
    Set rng = Range("A1:A100")
    colorIndex = -4142
    'What is the value of null color?
    
    rng.AutoFilter Field:=1, Criteria1:=colorIndex, Operator:=xlFilterCellColor
End Sub

调用 FilterBycolor()

当颜色索引 = -4142 时:

在此输入图片描述

这不是我想要的输出。

我尝试过 colorIndex =-4142 、xlNone 、 xlColorIndexAutomatic 、 xlColorIndexNone 、 None 、 Null 、 vbWhite 。

他们都没有达到我的期望。 请帮助我。谢谢!

excel vba excel-2010 excel-2007 vba7
1个回答
0
投票

请尝试

Rng.AutoFilter Field:=1, Operator:=xlFilterNoFill
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.