title: VBA - Conditional formatting: Excel 2010 won't work, Excel 2013 will
body: <p>I recently wrote a piece of code that detects (but doesn't select) a <code>Range</code> which must be conditional formatted and then calls a subroutine that does the job.</p>
  
  <pre><code>' Format
  For Each ws In Results.Sheets
      Format_em_all ws.Range(ws.Cells(15, 2), ws.Cells(15 + UBound(FreqToCompare), WrittenCells))
  Next ws
  </code></pre>
  
  <p>Where <code>ws</code> is declared as <code>Worksheet</code>, <code>Results</code> as <code>Workbook</code>, <code>FreqToCompare</code> is an array with no possibility of being empty and <code>WrittenCells</code>is an Integer not = 0.</p>
  
  <p>The Subroutine called:</p>
  
  <pre><code>Sub Format_em_all(RangeToFormat As Range)
  
      Select Case RangeToFormat.Parent.Name
  
      Case "lol"
          RangeToFormat.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="=2.9"
          RangeToFormat.FormatConditions(1).Interior.ColorIndex = 3
          RangeToFormat.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, Formula1:="=2.00001", Formula2:="=2.9"
          RangeToFormat.FormatConditions(2).Font.ColorIndex = 3
  
      Case "rofl"
          RangeToFormat.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotBetween, Formula1:="=-4", Formula2:="=4"
          RangeToFormat.FormatConditions(1).Interior.ColorIndex = 3
  
      End Select
  
  End Sub
  </code></pre>
  
  <p>I executed the code on my computer with Excel 2013 and all went smooth. 10 mins ago comes a colleague and says that my macro doesn't work... we go togheter to check on his computer with Excel 2010... and yeah, it doesn't work. It gets stuck at the first line after <code>Case "lol"</code> with a "Runtime error "5" - Invalid procedure call or argument".
  I tried to <code>? RangeToFormat.Address</code> and it shows the correct range address... What is wrong with it?</p>