如何仅为可见的单元格应用条件格式?

我正在使用Excel-2010,我已经应用Excel范围A1:F100的3scale条件格式,在下拉macros隐藏/取消隐藏将被动作,隐藏/取消隐藏不是顺序的,例如: – 行1,10,30, 54,67,88可能只可见。

所以只有这些可见的行,相同的条件格式应该工作。

我试过浏览find它,但我无法得到所需的。

帮助非常赞赏。

提前致谢。

正如所评论的,它应该是这样的:

Sub ject() Dim rng As Range With Sheet1 '~~> change to your actual sheet .Range("A1:F100").FormatConditions.Delete Set rng = .Range("A1:F100").SpecialCells(xlCellTypeVisible) .Range("A1").FormatConditions.AddColorScale 3 With .Range("A1").FormatConditions(1) With .ColorScaleCriteria(1) .Type = xlConditionValueLowestValue .FormatColor.Color = RGB(255, 0, 0) End With With .ColorScaleCriteria(2) .Type = xlConditionValuePercentile .FormatColor.Color = RGB(255, 255, 0) End With With .ColorScaleCriteria(3) .Type = xlConditionValueHighestValue .FormatColor.Color = RGB(0, 255, 0) End With .ModifyAppliesToRange rng End With End With End Sub 

每次运行或调用此例程时,都会将格式重新应用到可见范围。
它可以合并到一个现有的代码或单独运行。 HTH。

SUBTOTAL公式有最小,中点和最大值的可能性。

最小值:Type = Formula, =SUBTOTAL(105,$A$1:$F$100)

Midpoint:Type = Formula, =MEDIAN(IF((SUBTOTAL(103,INDIRECT("A"&ROW($1:$100)))>0)*($A$1:$F$100<>""),$A$1:$F$100))

最大值:Type = Formula, =SUBTOTAL(104,$A$1:$F$100)

如果你可以接受数值的平均值而不是50%的百分点作为中点,中点的公式会更简单:

 =SUBTOTAL(101,$A$1:$F$100) 

问候

阿克塞尔