title: VBA code showing "Compile error: Sub or function not defined"
body: <p>I have this following code which is showing this error: "Compile error: Sub or function not defined"</p>
  
  <pre><code>Dim wattarray() As Integer 
  Dim x As Integer
  
  x = Sheets("Names").Range("ai4")
  ReDim wattarray(x) As Integer
  Dim battarray As Variant
  If condition Then
      battarray = Array("32", "34", "36")
  End if
  
  For z = 1 To x
      watt = (kw * 1000 * dmarg) / (ieff * battarray(z) * tfac * agefac * 6 * nstring)
      wattarry(z) = watt      "this line shows the error"           
      watt = wattarry(1)
  Next z
  </code></pre>
  
  <p>battarray and wattarray have the same size as variable <code>x</code></p>
  
  <p>Can some one help me fix this...</p>