excel 对未隐藏的条件格式值进行计数

ygya80vv  于 2023-06-07  发布在  其他
关注(0)|答案(2)|浏览(176)

每个单元格的值为0,该行将被隐藏。以及在最小值和最大值之外的任何值 将是红色的。
如何识别红色但处于活动状态(未隐藏)?
我用了range.displayformat.interior.color = vbred
细胞是红色的,但隐藏的也被计数。

2izufjch

2izufjch1#

试试这个,可见的单元格将被格式化

Set rng = Range("Your range").SpecialCells(xlCellTypeVisible)
        rng = ActiveCell.DisplayFormat.Interior.Color = vbRed
gmxoilav

gmxoilav2#

下面是您请求的“if”条件的示例代码。

Sub Highlight_Greater_Than()

Dim ws As Worksheet
Dim Rng As Range
Dim ColorCell As Range

Set ws = Worksheets("Name")
Set rng = Range("Your range").SpecialCells(xlCellTypeVisible)
    'rng = ActiveCell.DisplayFormat.Interior.Color = vbRed
Set ColorCell = rng

For Each ColorCell In Rng
If ColorCell.Value > 1 Then      " You can define here"  "greater, smaller, equal  etc.."
ColorCell.Interior.Color = vbred

Else
ColorCell.Interior.ColorIndex = "vb(colour)or" xlNone
End If
Next

End Sub

相关问题