title: Why am I getting Error 2042 in VBA Match?
body: <p>I have Column A:</p>
  
  <pre><code>+--+--------+
  |  |  A     |
  +--+--------+
  | 1|123456  |
  |--+--------+
  | 2|Order_No|
  |--+--------+
  | 3|    7   |
  +--+--------+
  </code></pre>
  
  <p>Now if I enter:</p>
  
  <pre><code>=Match(7,A1:A5,0)
  </code></pre>
  
  <p>into a cell on the sheet I get </p>
  
  <pre><code>3
  </code></pre>
  
  <p>As a result. (This is desired)</p>
  
  <p>But when I enter this line:</p>
  
  <pre><code>Dim CurrentShipment As Integer
  CurrentShipment = 7
  CurrentRow = Application.Match(CurrentShipment, Range("A1:A5"), 0)
  </code></pre>
  
  <p>CurrentRow gets a value of "Error 2042"</p>
  
  <p>My first instinct was to make sure that the value 7 was in fact in the range, and it was.</p>
  
  <p>My next was maybe the Match function required a string so I tried </p>
  
  <pre><code>Dim CurrentShipment As Integer
  CurrentShipment = 7
  CurrentRow = Application.Match(Cstr(CurrentShipment), Range("A1:A5"), 0)
  </code></pre>
  
  <p>to no avail. </p>