【问题标题】:Access VBA - condition formatting with 2 different xlFormatCondictionTypes访问 VBA - 具有 2 种不同 xlFormatCondiction 类型的条件格式
【发布时间】:2016-01-27 21:13:15
【问题描述】:

我想在从 access 导出到 excel 时进行条件格式化。我必须检查条件 1(Type:=xlExpression) 和条件 2(Type:=xlTextString)。如果两者都为真,则在 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

如何将以上 2 个条件合并为一个条件。

谢谢,

【问题讨论】:

    标签: vba excel


    【解决方案1】:

    您帖子中的代码在某些区域有点到处都是,所以我对修复的假设可能有点偏差。不过,这些东西你可能很容易调整。

    就组合条件而言,只需在当前表达式的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
    

    【讨论】:

    猜你喜欢
    • 2016-02-03
    • 2016-01-03
    • 1970-01-01
    • 1970-01-01
    • 2017-11-13
    • 1970-01-01
    • 2019-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多