Strange / unstable behaviour on CreatePivotTable() <p>I am writing VBA code to automate some processes in Excel and I am encountering a very strange behavior for which I have not been able to find documentation / help.</p> <p>I have a procedure <code>MAJ_GF</code> that first executes function <code>GF.Update</code>, checks the result, and then launches procedure <code>GF.Build</code> (which basically takes the data obtained by <code>GF.Update</code> from different worksheets and does a bunch of stuff with it). </p> <p>At some point, this "bunch of stuff" requires using a pivot table, so <code>GF.Build</code> contains the following line:</p> <pre><code>Set pvt = ThisWorkbook.PivotCaches.Create(xlDatabase, _ "'source_GF'!R1C1:R" &amp; j &amp; "C" &amp; k).CreatePivotTable("'TCD_GF'!R4C1", "GFTCD1") </code></pre> <p><strong>The strange behavior is this:</strong></p> <ul> <li>when I run <code>MAJ_GF</code>, VBA properly executes <code>GF.Update</code>, then launches <code>GF.Build</code>, and stops at the line described above complaining "Bad argument or procedure call"</li> <li>when I manually run <code>GF.Update</code>, then manually run <code>GF.Build</code>, everything goes smoothly and <code>GF.Build</code> does what it has to do from beginning to end with no errors</li> <li>even stranger, when I set a break-point on the incriminated line, run <code>MAJ_GF</code> then VBA pauses on the line as expected, and when I say "Continue"... it just continues smoothly and with no errors !</li> </ul> <p>I turned this around and around and around, double-checked the value of every variable, and this just makes no sense.</p> <p>Ideas anybody?</p>