簡體   English   中英

使用 Access VBA 條件格式化 Excel 電子表格

[英]Conditional Formatting Excel Spreadsheet Using Access VBA

我正在嘗試在使用 MS Access 365 VBA 操作的電子表格上創建 2 種條件格式。 我創建了以下代碼來執行此操作:

        Set lrngReport = .Range("$A$2:$" & lstrLastCol & "$" & lintLastRow)
        With lrngReport
        
            .FormatConditions.Delete
            
            'Condition where no record in Donor Comments Modified
            .FormatConditions.Add Type:=xlExpression, Operator:=xlEqual, Formula1:="=OR(ISBLANK($J2),$J2<>'Yes')"
             With .FormatConditions(1)
                .Interior.Color = RGB(255, 243, 109)
                .Font.Bold = True
                .StopIfTrue = False
            End With
        
            'Not reviewed condition
            .FormatConditions.Add Type:=xlExpression, Formula1:="=OR(ISBLANK($L2),$L2<>'Yes'"
            With .FormatConditions(2)
                .Font.Color = RGB(225, 6, 0)
                .Font.Bold = True
                .StopIfTrue = False
            End With
            
        End With

代碼在第 4 行失敗

 .FormatConditions.Add Type:=xlExpression, Operator:=xlEqual, Formula1:="=OR(ISBLANK($J2),$J2<>'Yes')"

錯誤無效的過程調用或參數。

我究竟做錯了什么?

Excel 不喜歡撇號分隔符,需要引號。 加倍以將它們轉義為文字文本。

Formula1:="=OR(ISBLANK($J2),$J2<>""Yes"")"

暫無
暫無

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

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