title: Not treating empty cells as zero
body: <p>I'm working on a function to do linear interpolation:</p>
  
  <pre><code>Public Function linear_interpolation(xs As Range, ys As Range, x As Double)
      Dim index As Integer
      Dim x0 As Double, x1 As Double
      Dim y0 As Double, y1 As Double
      index = Application.WorksheetFunction.Match(x, xs)
      x0 = xs(index)
      y0 = ys(index)
      x1 = xs(index + 1)
      y1 = ys(index + 1)
      linear_interpolation = ((x1 - x) * y0 + (x - x0) * y1) / (x1 - x0)
  End Function
  </code></pre>
  
  <p>It works fine if both ranges <code>xs</code> and <code>ys</code> are fully populated, but if there is a missing value (empty cell) then it is treated as a zero, which is surprising, I was expecting a type error. If the cell contains a non-numerical value, then I get <code>#VALUE!</code> as expected.</p>
  
  <p>What's the best way of dealing with this? Do I have to manually check to see if <code>xs(index)</code>, <code>ys(index)</code>, <code>xs(index+1)</code> and <code>ys(index+1)</code> empty and then return an error?</p>