title: How to do conditional formating an Excel VBA macro?
body: <p><a href="/questions/tagged/vba" class="post-tag" title="show questions tagged 'vba'" rel="tag">vba</a>
  I have used the below code to insert conditional formatting in an excel cell..</p>
  
  <pre><code>range("d" &amp; rowno).Select
  Selection.Offset(1, 0).EntireRow.Insert
  Selection.FormatConditions.Add Type:=xlExpression, Formula1:="= RC &gt; 7"
  Selection.FormatConditions(Selection.FormatConditions.count).SetFirstPriority
  With Selection.FormatConditions(1).Interior
      .PatternColorIndex = xlAutomatic
      .Color = 65535 'Yellow
      .TintAndShade = 0
  End With
  </code></pre>
  
  <p>The above works fine by comparing the grater than value defined which is "7"...
  But if i pass variable "lhigh" in which value is stored  and the same im passing it in the formaula it does not works.
  e.g;
      <code>lhigh=7</code>     </p>
  
  <pre><code>range("d" &amp; rowno).Select
  Selection.Offset(1, 0).EntireRow.Insert
  Selection.FormatConditions.Add Type:=xlExpression, Formula1:="= RC &gt; lhigh"
  Selection.FormatConditions(Selection.FormatConditions.count).SetFirstPriority
  With Selection.FormatConditions(1).Interior
      .PatternColorIndex = xlAutomatic
      .Color = 65535 'Yellow
      .TintAndShade = 0
  End With
  </code></pre>
  
  <p>Please let me know how we can than calculate greater than check if we pass variable instead of direct integer value</p>