如何通过程序取得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

原文地址:https://www.cnblogs.com/chenxizhang/p/1381861.html