簡體   English   中英

訪問VBA-使用2種不同的xlFormatCondictionTypes進行條件格式化

[英]Access VBA - condition formatting with 2 different xlFormatCondictionTypes

我想從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個條件組合為一個條件。

謝謝,

您帖子中的代碼在某些區域到處都是,所以我對修復程序的假設可能會有些偏離。 但是,您可能可以輕松調整這些內容。

至於組合條件,只需在當前表達式的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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM