title: Convert Error 2306 to 0 in VBA
body: <p>I am writing out a Macro that smooths data to reduce jagged edges etc. </p>
  
  <p>I need a way to replace cells which produce Errors, such as Error 2036 or <code>#Num</code> values in cells to <code>0</code> I would like to do this within the <code>For loop</code> as the previous values is used in calculating this value. </p>
  
  <p>I have tried to <code>If</code> statements to solve this but to no avail. </p>
  
  <p>The code I have tried to use is as follows. </p>
  
  <p>The 3 code variations are from the definations from teh excel website naming what the error is. </p>
  
  <pre><code>If LineAngle = xlErrNum Then
      LineAngle = 0
  End If
  </code></pre>
  
  <p>or </p>
  
  <pre><code>If LineAngle = "Error 2036 Then
      LineAngle = 0
  End If
  </code></pre>
  
  <p>or </p>
  
  <pre><code>If LineAngle = "#Num" Then
      LineAngle = 0
  End If
  </code></pre>
  
  <p>Which ever code I run I always get  <strong>Run-time error 13 Type mismatch</strong></p>
  
  <p>Any help you are able to provide is very useful.
  Thanks </p>