Note that there are some explanatory texts on larger screens.

plurals
  1. PO#VALUE! errors after setting displayed outline level from VBA
    primarykey
    data
    text
    <p>I have reduced my problem to the following test case:</p> <ol> <li><p>create a new workbook;</p></li> <li><p>enter a constant value, e.g. <code>123</code> into <code>Sheet1!A1</code>;</p></li> <li><p>define a name, e.g. <code>foo</code>, that refers to the formula <code>=CHOOSE(!$A$1, Sheet1!$A$1)</code>;</p></li> <li><p>enter the constant value <code>1</code> into <code>Sheet2!A1</code>;</p></li> <li><p>enter the formula <code>=foo</code> into some other cell on <code>Sheet2</code>, e.g. <code>Sheet2!B1</code>: observe that, as expected, the result is the value that was entered into <code>Sheet1!A1</code> in step 2 above;</p></li> <li><p>create then run a VBA procedure containing the following code:</p> <pre><code>Sheets("Sheet1").Outline.ShowLevels 1 </code></pre></li> </ol> <p>You will notice that the cell from step 5 now contains a <code>#VALUE!</code> error.</p> <p>Moreover, a simple sheet recalculation (whether using the <kbd>F9</kbd> key or the <code>Application.Calculate</code> method) does not resolve the problem: one must instead perform either a <em>full</em> recalculation from VBA (using the <code>Application.CalculateFull</code> method) or else a <em>full rebuild</em> from the interactive UI (using the <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>SHIFT</kbd>+<kbd>F9</kbd> key combination).</p> <p>Through trial-and-error, I have ascertained that for this condition to arise:</p> <ul> <li><p>the <code>CHOOSE()</code> index argument must involve a relative-sheet cell reference (not constants or absolute-sheet references);</p></li> <li><p>the <code>CHOOSE()</code> value argument that is being indexed must involve a reference to another sheet;</p></li> <li><p>the change of displayed outline level must arise from within a VBA <em>procedure</em> (not from the outline controls in the interactive UI or the VBA Immediate Window); and</p></li> <li><p>the <code>ShowLevels</code> method call (whose arguments are irrelevant) must be applied to a sheet that is referenced amongst any of the value (though not index) arguments to <code>CHOOSE()</code>.</p></li> </ul> <p>What's going on?</p> <p>I would very much like to collapse a worksheet that I am referencing amongst the value arguments to <code>CHOOSE()</code> to its highest outline level without triggering this error, as a full recalculation of my actual workbook (still only a few seconds) is undesirable from a UX standpoint.</p> <p>Suggestions for a workaround (whilst still using a defined name containing the <code>CHOOSE()</code> function together with a relative-sheet index argument) would be most welcome!</p> <p>My platform: Excel 2010 (14.0.6123.5001, 32-bit) on Windows 7 Home Premium (SP1, 64-bit).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload