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

1

2 Answers 2

0

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

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

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! Thank you Erin!
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.