0

I found this answer for an Excel VBA, but I'm having trouble converting it to Access VBA (Conditional Formatting using Excel VBA code).

Here's my current code:

    with ws
         With .Cells(1, 1).FormatConditions.Add(Type:=xlExpression, Formula1:="=IF($J2=""Y"";TRUE;FALSE)")
            .Font.Color = -10092544
            .StopIfTrue = False
            StrSearchCriteria = "A2:D" & lRow
            .FormatConditions(1).ModifyAppliesToRange Range(StrSearchCriteria)
        End With
        With .Cells(1, 1).FormatConditions.Add(xlCellValue, xlEqual, "=""Closed (New)""")
            .Font.Color = -16776961
            .StopIfTrue = False
            StrSearchCriteria = "A2:K" & lRow
            .FormatConditions(2).ModifyAppliesToRange Range(StrSearchCriteria)
        End With
    End With

I'm getting the error "Invalid procedure call or argument".

What am I missing? Thanks

LEBoyd
  • 151
  • 12
  • I found this answer https://stackoverflow.com/questions/13125467/adding-a-format-condition-in-excel-through-access-vba. – LEBoyd Apr 23 '18 at 17:49

2 Answers2

0

I found this answer: Adding a format condition in Excel through Access VBA.

However, when I simply try to delete any existing conditional formats (as a test of the method with code from the linked answer) I receive the error "Object does not support this property or method." The code is:

with wks
    .Range("A:D").Selection.FormatConditions.Delete
end with

Any help on this is greatly appreciated.

LEBoyd
  • 151
  • 12
0

You shouldn't need to reference the selection. Try:

.Range("A:D").FormatConditions.Delete

Erin B
  • 90
  • 9