title: Colour Filling using VBA, Conditional on cell value
body: <p>I am looking to colour fill a range of cells (C2:C7) in Excel based on the the text selected in a cell (there will be a drop-down menu, two of the values being "SD" and "CS"). Here is my code so far: </p>
  
  <p>Sub ChangeColor()
      Dim rCell As Range</p>
  
  <pre><code>With Sheet1
  For Each rCell In .Range("C2:C7")
  
  If rCell.Value &lt;= SD Then
  rCell.Interior.Color = vbRed
  ElseIf rCell.Value &lt;= CS Then
  rCell.Interior.Color = vbGreen
  Else: rCell.Interior.Color = vbYellow
  End If
  End With
  
  End Sub
  </code></pre>
  
  <p>I'm told there is a compile error: End With without With </p>
  
  <p>I'm just getting started in VBA so can somebody please tell me what I've done wrong? </p>