VBA Excel error, while attempting to write a value from array in a cell
<p>I have a big VBA script, that starts an external program, waits, then reads the results into several arrays and writes some values in a table.
So I regularly get an error at the following place</p>

<pre><code>Sheets("Calc").Cells(active_line_num, 1).Value = PiKa(i, j)
</code></pre>

<p>where <em>PiKa</em> is an array; 
<em>i</em>, <em>j</em> are feasible indices,</p>

<p><em>active_line_num</em> has also a totally feasible value.
These lines are in the outer loop, and mostly it works w/o problems. But at some iterations it stops.</p>

<p>So the program breakes and suggests me to debug it. 
In debugging mode if I press F8 immidiately (next step) it reproduces the error.
But afteer some time (a minute or two) if I press F8 - everythig is running further w/o any errors.</p>

<p>The error is <strong>Run-Time Error '9', Subscript out of range</strong>     </p>

<p>Here are two printscreens <a href="http://imgur.com/a/MOPwd" rel="nofollow">imgur.com/a/MOPwd</a> 
One can see, that PiKa (9,6) as well as next 4 arrays exist and even have nonzero values. 
All these arrays are defined in the module as </p>

<pre><code>Public PiKa() as Double 
</code></pre>

<p>w/o dimentions and then are redimentioned once at the very beginnig of the program (not in the loops!) </p>

<pre><code>ReDim PiKa(0 To nrc, 0 To 99) 
</code></pre>

<p>What can it be?</p>