title: Adding a format condition in Excel through Access VBA
body: <p>So currently i got these lines in my code, </p>
  
  <pre><code>.Range("C2").Formula = "=IF(B2 = """"," &amp; """REQUIRED""" &amp; "," &amp; """""" &amp; ") "
  .Range("C3").Formula = "=IF(B3 = """"," &amp; """REQUIRED""" &amp; "," &amp; """""" &amp; ") "
  </code></pre>
  
  <p>my goal was to add a conditional formatting to it, so if it equal to Required from the range =$C$2:$C$3 turn background red so far ive seen some codes online but none of them seem to apply. I modified some existing code for my purposes by i get an error on xlExpression "variable not defined". Can anyone help me?</p>
  
  <pre><code>.Range("C2:C3").Selection.FormatConditions.Delete 
  .Range("C2:C3").Selection.FormatConditions.Add TYPE:=xlExpression, Formula1:="=(=$C$2:$C$23 = 'REQUIRED')"
  </code></pre>