title: Casting a string to a boolean operator (<, <=, >, >=)
body: <p>In cell <code>A1</code>, there can be either <code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code> or <code>&gt;=</code> (of string).</p>
  
  <p>In cell <code>B1</code>, there's the threshold's value of int.</p>
  
  <p>From <code>A3</code>, there are values of int.</p>
  
  <pre><code>+---+-----+----+
  |   | A   | B  |
  +---+-----+----+
  | 1 | &lt;   | 15 |
  | 2 |     |    |
  | 3 | 10  |    |
  | 4 | 20  |    |
  | 5 | ... |    |
  +---+-----+----+
  </code></pre>
  
  <p>The value in <code>A3</code> should be copied in <code>B3</code> if and only if it respects the boolean operator (<code>A1</code>) and the threshold (<code>B1</code>). Otherwise, <code>B3</code> should be <code>#N/A</code>. Of course, the same for <code>A4</code>/<code>B4</code>, <code>A5</code>/<code>B5</code>, etc.</p>
  
  <p>In that example, <code>B3</code> should be <code>10</code> and <code>B4</code> should be <code>#N/A</code>, because 10 is less than 15, but 20 isn't.</p>
  
  <p>Here is a formula I created which works great, but which is a bit long (this is for <code>B3</code>):</p>
  
  <pre><code>=IF($A$1 = "&lt;"; IF($A3 &lt; $B$1; $A3; NA()); IF($A$1 = "&lt;="; IF($A3 &lt;= $B$1; $A3; NA()); IF($A$1 = "&gt;"; IF($A3 &gt; $B$1; $A3; NA()); IF($A3 &gt;= $B$1; $A3; NA()))))
  </code></pre>
  
  <p>The same in a more digest way:</p>
  
  <pre><code>=IF(
      $A$1 = "&lt;";
      IF($A3 &lt; $B$1;$A3; NA());
      IF(
          $A$1 = "&lt;=";
          IF($A3 &lt;= $B$1; $A3; NA());
          IF(
              $A$1 = "&gt;";
              IF($A3 &gt; $B$1; $A3; NA());
              IF($A3 &gt;= $B$1; $A3; NA())
          )
      )
  )
  </code></pre>
  
  <p>Is there any more convenient way to do that job? Casting from a string to an operator would be great, but yeah, I dunno any programing language capable of doing such kind of stuff <code>:)</code> Ideally, it should be something like <code>=IF($A3 $A$1 $B$1; $A3; NA())</code>...</p>