<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CEILING Part 3</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2007/06/21/ceiling-part-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2007/06/21/ceiling-part-3/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 18:06:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Parker Kimm</title>
		<link>http://www.dailydoseofexcel.com/archives/2007/06/21/ceiling-part-3/#comment-24984</link>
		<dc:creator>Parker Kimm</dc:creator>
		<pubDate>Sat, 23 Jun 2007 01:13:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1689#comment-24984</guid>
		<description>&lt;p&gt;Case &quot;22?&lt;br&gt;
      Debug.Assert nrL = srL And ncL = scL&lt;br&gt;
      If nrU = srU And ncU = scU Then&lt;br&gt;
        ReDim vRes(nrL To nrU, ncL To ncU)&lt;br&gt;
        For r = nrL To nrU: For c = ncL To ncU: vRes(r, c) = GetCeiling(vNum(r, c), vSig(r, c)): Next: Next&lt;br&gt;
      Else&lt;br&gt;
        Dim nrX As Long, srX As Long, ncX As Long, scX As Long&lt;br&gt;
        If nrU = 1 Then nrU = srU Else nrX = 1&lt;br&gt;
        If srU = 1 Then srU = nrU Else srX = 1&lt;br&gt;
        If ncU = 1 Then ncU = scU Else ncX = 1&lt;br&gt;
        If scU = 1 Then scU = ncU Else scX = 1&lt;br&gt;
        nrU = Application.Max(nrU, srU)&lt;br&gt;
        ncU = Application.Max(ncU, scU)&lt;br&gt;
        ReDim vRes(nrL To nrU, ncL To ncU)&lt;/p&gt;
&lt;p&gt;        For r = 0 To nrU - nrL&lt;br&gt;
          For c = 0 To ncU - ncL&lt;br&gt;
            vRes(nrL + r, ncL + c) = CVErr(xlErrNA)&lt;br&gt;
            vRes(nrL + r, ncL + c) = GetCeiling(vNum(nrL + r * nrX, ncL + c * ncX), vSig(srL + r * srX, scL + c * scX))&lt;br&gt;
          Next&lt;br&gt;
        Next&lt;br&gt;
     End If&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Case &#8220;22?<br />
      Debug.Assert nrL = srL And ncL = scL<br />
      If nrU = srU And ncU = scU Then<br />
        ReDim vRes(nrL To nrU, ncL To ncU)<br />
        For r = nrL To nrU: For c = ncL To ncU: vRes(r, c) = GetCeiling(vNum(r, c), vSig(r, c)): Next: Next<br />
      Else<br />
        Dim nrX As Long, srX As Long, ncX As Long, scX As Long<br />
        If nrU = 1 Then nrU = srU Else nrX = 1<br />
        If srU = 1 Then srU = nrU Else srX = 1<br />
        If ncU = 1 Then ncU = scU Else ncX = 1<br />
        If scU = 1 Then scU = ncU Else scX = 1<br />
        nrU = Application.Max(nrU, srU)<br />
        ncU = Application.Max(ncU, scU)<br />
        ReDim vRes(nrL To nrU, ncL To ncU)</p>
<p>        For r = 0 To nrU &#8211; nrL<br />
          For c = 0 To ncU &#8211; ncL<br />
            vRes(nrL + r, ncL + c) = CVErr(xlErrNA)<br />
            vRes(nrL + r, ncL + c) = GetCeiling(vNum(nrL + r * nrX, ncL + c * ncX), vSig(srL + r * srX, scL + c * scX))<br />
          Next<br />
        Next<br />
     End If</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2007/06/21/ceiling-part-3/#comment-24961</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Fri, 22 Jun 2007 10:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1689#comment-24961</guid>
		<description>&lt;p&gt;Yep, missed that. Repaired &quot;case 22? as follows:&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;22&quot;&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; Debug.Assert nrL = srL &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; ncL = scL&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; nrU = srU &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; ncU = scU &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; vRes(nrL &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; nrU, ncL &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; ncU)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; r = nrL &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; nrU: &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; c = ncL &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; ncU: vRes(r, c) = GetCeiling(vNum(r, c), vSig(r, c)): &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; nrX &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, srX &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, ncX &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, scX &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; nrU = 1 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; nrU = srU &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt; nrX = 1&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; srU = 1 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; srU = nrU &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt; srX = 1&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; ncU = 1 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; ncU = scU &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt; ncX = 1&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; scU = 1 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; scU = ncU &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt; scX = 1&lt;br&gt;
&#160; &#160; &#160; &#160; nrU = Application.Max(nrU, srU)&lt;br&gt;
&#160; &#160; &#160; &#160; ncU = Application.Max(ncU, scU)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; vRes(nrL &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; nrU, ncL &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; ncU)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; r = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; nrU - nrL&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; c = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; ncU - ncL&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; vRes(nrL + r, ncL + c) = CVErr(xlErrNA)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; vRes(nrL + r, ncL + c) = GetCeiling(vNum(nrL + r * nrX, ncL + c * ncX), vSig(srL + r * srX, scL + c * scX))&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Remaining challenge&lt;br&gt;
return #Value! for non array-entered arrays, BUT return array in editmode&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; IsArray(vRes) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;With&lt;/span&gt; Application&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;TypeOf&lt;/span&gt; .Caller &lt;span class=&quot;kw1&quot;&gt;Is&lt;/span&gt; Range &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Not&lt;/span&gt; .Caller.HasArray &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; vRes = CVErr(xlErrValue)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;With&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;however return vRes in editmode.. I&#039;ve tried Application.Ready (xp+) but it doens&#039;t work.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Yep, missed that. Repaired &#8220;case 22? as follows:</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer">&nbsp; &nbsp; <span class="kw1">Case</span> <span class="st0">&#8220;22&#8243;</span><br />
&nbsp; &nbsp; &nbsp; Debug.Assert nrL = srL <span class="kw1">And</span> ncL = scL<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> nrU = srU <span class="kw1">And</span> ncU = scU <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">ReDim</span> vRes(nrL <span class="kw1">To</span> nrU, ncL <span class="kw1">To</span> ncU)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">For</span> r = nrL <span class="kw1">To</span> nrU: <span class="kw1">For</span> c = ncL <span class="kw1">To</span> ncU: vRes(r, c) = GetCeiling(vNum(r, c), vSig(r, c)): <span class="kw1">Next</span>: <span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Dim</span> nrX <span class="kw1">As</span> <span class="kw1">Long</span>, srX <span class="kw1">As</span> <span class="kw1">Long</span>, ncX <span class="kw1">As</span> <span class="kw1">Long</span>, scX <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> nrU = 1 <span class="kw1">Then</span> nrU = srU <span class="kw1">Else</span> nrX = 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> srU = 1 <span class="kw1">Then</span> srU = nrU <span class="kw1">Else</span> srX = 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> ncU = 1 <span class="kw1">Then</span> ncU = scU <span class="kw1">Else</span> ncX = 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> scU = 1 <span class="kw1">Then</span> scU = ncU <span class="kw1">Else</span> scX = 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; nrU = Application.Max(nrU, srU)<br />
&nbsp; &nbsp; &nbsp; &nbsp; ncU = Application.Max(ncU, scU)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">ReDim</span> vRes(nrL <span class="kw1">To</span> nrU, ncL <span class="kw1">To</span> ncU)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">For</span> r = 0 <span class="kw1">To</span> nrU &#8211; nrL<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">For</span> c = 0 <span class="kw1">To</span> ncU &#8211; ncL<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vRes(nrL + r, ncL + c) = CVErr(xlErrNA)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vRes(nrL + r, ncL + c) = GetCeiling(vNum(nrL + r * nrX, ncL + c * ncX), vSig(srL + r * srX, scL + c * scX))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">End</span> <span class="kw1">If</span></div>
</div>
<p>Remaining challenge<br />
return #Value! for non array-entered arrays, BUT return array in editmode</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">If</span> IsArray(vRes) <span class="kw1">Then</span><br />
&nbsp; &nbsp; <span class="kw1">With</span> Application<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> <span class="kw1">TypeOf</span> .Caller <span class="kw1">Is</span> Range <span class="kw1">Then</span> <span class="kw1">If</span> <span class="kw1">Not</span> .Caller.HasArray <span class="kw1">Then</span> vRes = CVErr(xlErrValue)<br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">With</span><br />
<span class="kw1">End</span> <span class="kw1">If</span></div>
</div>
<p>however return vRes in editmode.. I&#8217;ve tried Application.Ready (xp+) but it doens&#8217;t work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2007/06/21/ceiling-part-3/#comment-24945</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Fri, 22 Jun 2007 00:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1689#comment-24945</guid>
		<description>&lt;p&gt;The problem is in Case &quot;22?. Specifically, when vNum is M-by-N and vSig is M-by-1,&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; c = ncL &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; ncU&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; c &lt;&amp;eq; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(vNum, 2) &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; c &lt;&amp;eq; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(vSig, 2) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The problem is that ncL = 1, ncU = 2, and UBound(vNum, 2) = 2, BUT UBound(vSig, 2) = 1. That means that on the second iteration when c = 2, the second test above fails, which leads to an #N/A entry in the result array.&lt;/p&gt;
&lt;p&gt;You made nrU = 1 and scU = 1 special cases. You should also have made ncU = 1 and scU = 1 special cases. But that doesn&#039;t fix things. With {8,7.5;10,10} in D3:E4 and {2,2.5,} in D1:F1,&lt;/p&gt;
&lt;p&gt;=kicceiling(D3:E4,D1:F1)&lt;/p&gt;
&lt;p&gt;returns {8,10,0;10,10,0} while&lt;/p&gt;
&lt;p&gt;=CEILING($D$3:$E$4,$D$1:$F$1)&lt;/p&gt;
&lt;p&gt;returns {8,7.5,#N/A;10,10,#N/A}, so you still have a bug in your array iteration AND you have a bug in GetCeiling.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>The problem is in Case &#8220;22?. Specifically, when vNum is M-by-N and vSig is M-by-1,</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">For</span> c = ncL <span class="kw1">To</span> ncU<br />
&nbsp; <span class="kw1">If</span> c &amp;lt;&amp;eq; <span class="kw1">UBound</span>(vNum, 2) <span class="kw1">And</span> c &amp;lt;&amp;eq; <span class="kw1">UBound</span>(vSig, 2) <span class="kw1">Then</span></div>
</div>
<p>The problem is that ncL = 1, ncU = 2, and UBound(vNum, 2) = 2, BUT UBound(vSig, 2) = 1. That means that on the second iteration when c = 2, the second test above fails, which leads to an #N/A entry in the result array.</p>
<p>You made nrU = 1 and scU = 1 special cases. You should also have made ncU = 1 and scU = 1 special cases. But that doesn&#8217;t fix things. With {8,7.5;10,10} in D3:E4 and {2,2.5,} in D1:F1,</p>
<p>=kicceiling(D3:E4,D1:F1)</p>
<p>returns {8,10,0;10,10,0} while</p>
<p>=CEILING($D$3:$E$4,$D$1:$F$1)</p>
<p>returns {8,7.5,#N/A;10,10,#N/A}, so you still have a bug in your array iteration AND you have a bug in GetCeiling.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

