如何通过程序取得Excel中条件格式的结果

例如有这么一个需求,我们在Excel模板中设置了条件格式,通过程序往里面输入数值。我们需要统计满足条件格式为红色的个数。代码大致如下

If temprng.FormatConditions.Count > 0 Then

'如果有条件格式

'则查找颜色为红色的条件格式

For Each fc As Excel.FormatCondition In temprng.FormatConditions

If fc.Interior.Color = 255 AndAlso app.Evaluate(fc.Formula1) Then

redcount = redcount + 1

End If

Next

End If

posted @ 2009-02-01 10:20  陈希章  阅读(1067)  评论(0编辑  收藏  举报