• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Conditional format cells with formula

Villalobos

Active Member
Hello,

I would some help regarding conditional formatting with formula. My target is to change the interior color of cell (in column L until the lastrow -the original file has some thousand rows-) if the formula is turn to "true". Unfortunately I receive "Invalid procedure or argument" error msg at this line:

Code:
 .Range("L9:L" & OutputLastRow).FormatConditions.Add Type:=xlExpression, Formula1:="=AND(J9>0,K9<J9,O9>0,P9>TODAY())"

The full code is here:

Code:
Sub test()
Dim outputSheet4 As Worksheet
Dim OutputLastRow As Long

Set outputSheet4 = Worksheets("Evaluation")

  With outputSheet4
  OutputLastRow = .Cells(.Rows.Count, "L").End(xlUp).Row
  .Range("L9:L" & OutputLastRow).FormatConditions.Delete
  .Range("L9:L" & OutputLastRow).FormatConditions.Add Type:=xlExpression, Formula1:="=AND(J9>0,K9<J9,O9>0,P9>TODAY())"
  .Range("L9:L" & OutputLastRow).FormatConditions(1).Interior.Color = RGB(255, 0, 0)
  .Range("L9:L" & OutputLastRow).FormatConditions(1).Font.Color = RGB(255, 255, 255)
  .Range("L9:L" & OutputLastRow).FormatConditions(1).Font.Bold = True
  End With
 End Sub


Could somebody give me some advice how to solve this problem?

I attached the sample file as well.



Thanks in advance the help!
 

Attachments

  • sample.xlsm
    17.9 KB · Views: 1
Hi Narayan,

It is strange, on my side the problem still open. Maybe I have some customizing problem with XL?

PS: Do you know any other way to do the conditional formatting by vba?
 
Back
Top