UPDATE:
I try to use conditional formatting for the following case:
If a cell in column C (starting with C9) Tabelle3.Range(Tabelle3.Cells(9, 3), Tabelle3.Cells(lastcell, 3))
- is not empty
Cell <>""AND - fullfills a criteria which is stated in Tabelle4 Cell B2
Tabelle4.Range("B2")
its Interior.Color should be changed to Cellclr and its Font.Color to Fontclr
Start Old Post: I looked through various posts about conditional formatting but I couldn't find any, that is preciously solving my problem.
I want to apply conditional formatting to a Excel workbook which will be constantly extanded. Therefore, I wrote the following code:
Sub ConForm()
Dim lastcell As Long
Dim Cellclr As Long
Dim Fontclr As Long
lastcell = Tabelle3.Range("A1048576").End(xlUp).Row
Cellclr = RGB(232, 245, 246)
Fontclr = RGB(26, 155, 167)
Set C = Tabelle3.Range(Tabelle3.Cells(9, 3), Tabelle3.Cells(lastcell, 3))
With C.FormatConditions.Add( _
Type:=xlExpression, _
Formula1:="=AND($C9<>"""";"$C9.Value <= Tabelle4.Range(""B2"").Value)")
.Interior.Color = Cellclr
.Font.Color = Fontclr
End With
End Sub
If I just use the following range and formula:
Range("C9")
Formula1:="=C9<>""""")
the code works out for Cell C9. However, as already mentioned, it should be this Formula
=AND($C9<>"""";"$C9.Value <= Tabelle4.Range(""B2"").Value
be applied for the range
Tabelle3.Range(Tabelle3.Cells(9, 3), Tabelle3.Cells(lastcell, 3))
Does someone know where I made a mistake/mistakes and how to solve this issue?
End Subis in red text. So is theEnd With. Red text is strings or numbers. Since I'm not sure what the formula should look like once it's in the conditional formatting, I'm not sure where there is a missing/extra"; but you should definitely take a closer look at that string....