[AccessD] Help with creating an Excel Conditional Format from within Access

David McAfee davidmcafee at gmail.com
Thu Feb 2 14:19:05 CST 2012


The export works great, I'm having trouble with the conditional formatting:

        With .Worksheets("R6Payouts").Columns("M:M")
            .Select

'*****************Causes error
'Line below , is the original line, gets a compile error
'Access VBA Compiler doesn't like xlCellValueand xlLess
            .FormatConditions.Add Type:=xlCellValue, Operator:=xlLess,
Formula1:="=0"
'If I put quotes around the values, I get runtime err 13, Type mismatch:
           .FormatConditions.Add Type:="xlCellValue", Operator:="xlLess",
Formula1:="=0"
'I tried brackets, but that gives me err 2465 can't find field '|' in my
expression
            '.FormatConditions.Add Type:=([xlCellValue]),
Operator:=(objXL.[xlLess]), Formula1:="=0"
            .FormatConditions(.FormatConditions.Count).SetFirstPriority
'********************************
            With .FormatConditions(1).Font
                .Color = -16777024
                .TintAndShade = 0
            End With
            With .FormatConditions(1).Interior
                .PatternColorIndex = "xlAutomatic"
                .ThemeColor = "xlThemeColorAccent2"
                .TintAndShade = 0.799981688894314
            End With
            .FormatConditions(1).StopIfTrue = True
        End With




Any ideas?

TIA
David

From: David McAfee <davidmcafee at GMAIL.COM>
>


> Cross posted, sorry to those of you on both lists.
>
>
> I have this stored procedure that I export into an excel sheet.
> I'd like to add two conditional formats that highlight column M (light) red
> (pink?) if the value is <0.
> The other format would color column N Yellow if the value >.2 (20%)
>
> I could do the coloring, but the user wants the conditional formatting
> instead in case they play with the sheet's numbers.
>
> Does anyone know how to do this off the top of their head?
>


More information about the AccessD mailing list