I have looked over this forum, but I don't seem to find an answer to my question.
I have a dynamic range, based on the amount of columns and rows and want to format the cells according to different rules. However, I don't seem to be able to do so.
The range that needs to be formatted starts at K5 and is dynamic
Conditions:
- Value of cell > 0
- Value of row in column C = "BAU"
Whenever I run my code, I get an error '5' Invalid procedure call or argument. Here is my code:
Sub FormatAuswertung()
Dim last_row As Long, last_column As Long
Dim rngBlue As Range
Dim conditionBlue1 As FormatCondition
last_row = Worksheets("Auswertung2").Cells(rows.Count, 2).End(xlUp).Row
last_column = Worksheets("Auswertung2").Cells(4, Columns.Count).End(xlToLeft).Column
Set rngBlue = Range("K5", Cells(last_row, last_column))
Set conditionBlue1 = rngBlue.FormatConditions.Add(xlExpression, xlFormula, "=AND($C5=""BAU"",K5>0)")
With conditionBlue1
.Interior.Color = RGB(0, 255, 255)
End With
End Sub
Can anyone tell me what I am doing wrong?
Thank you! :)