访问VBA – 条件格式与2个不同的xlFormatCondictionTypes

我想从访问excel导出条件格式。 我必须检查条件1(Type:= xlExpression)和条件2(Type:= xlTextString)。 如果两者均为true,则使用excel中的任何颜色突出显示该行。 这是我的代码:

With xlSheet Set range = .Range("A1:L1") Sheets("xyz").Select range.FormatConditions.Add Type:=xlExpression, Formula1:="=AND($I1>=TODAY(),($I1<(TODAY()+30)))" rng.FormatConditions.Add Type:=xlTextString, String:="Focus", TextOperator:=xlContains With rng.FormatConditions(1).Interior .Color = Any color End With End With 

作为一个条件,我如何结合以上两个条件。

谢谢,

在你的文章中的代码是在某些地区的所有地方,所以我对修复的假设可能有点closures。 但是,这些东西你可能很容易调整。

就条件而言,只要在当前expression式的AND包装中放置另一个公式即可。

 With xlSheet Set range = .Range("A1:L1") range.FormatConditions.Add Type:=xlExpression, Formula1:="=AND($I1>=TODAY(),($I1<(TODAY()+30),NOT(ISERROR(FIND(""Focus"",$I1))))" With range.FormatConditions(1).Interior .Color = Any color End With End With