<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">

    <title type="text">cellmatrix.net</title>
    <subtitle type="text">cellmatrix.net:Featuring the Study of Microsoft Excel and Related Topics.</subtitle>
    <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/index/" />
    <link rel="self" type="application/atom+xml" href="http://www.cellmatrix.net/index.php/site/atom/" />
    <updated>2008-06-21T04:01:32Z</updated>
    <rights>Copyright (c) 2008, jfm</rights>
    <generator uri="http://www.pmachine.com/" version="1.6.3">ExpressionEngine</generator>
    <id>tag:cellmatrix.net,2008:06:21</id>


    <entry>
      <title>Contest &#45; Excel Models for Science and Engineering</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/contest_excel_models_for_science_and_engineering/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.95</id>
      <published>2008-06-21T03:34:00Z</published>
      <updated>2008-06-21T04:01:32Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="General"
        scheme="http://www.cellmatrix.net/index.php/site/category/General/"
        label="General" />
      <content type="html"><![CDATA[
        <p>Jon Peltier's <a href="http://peltiertech.com/WordPress/" title="PTS Blog">PTS Blog</a> is holding a contest to "highlight scientific and engineering applications of Microsoft Excel, by sharing models that users have built."</p>

<p><i>"The intent is to highlight scientific and engineering applications of Microsoft Excel, by sharing models that users have built."</i></p>

<p><i>"The contest winner will receive a copy of Excel MVP Bernard Liengme’s Guide to Microsoft Excel 2002 for Scientists and Engineers.  This is the Excel 2002 edition of the book. The Excel 2007 edition will not be out until this fall, but any lessons learned in the Excel 2002 version will be applicable to Excel 2007, though some of the specific commands may have changed."</i></p>

<p>As a sidenote, when I entered college I wanted to be an engineer.  Everything was going great until I hit the second Chemistry and specifically calculations for molarity and molality.  For some reason I just couldn't get it.  Eventually I went to the professor and asked to drop the class (at that time you had to have the professor sign the drop slip before you could get out.)  After an hour of stern lecturing by the professor because, in his view, I wasn't studying enough, he finally signed the slip.  Sadly, that was the end of my engineering career.  Now I do financial analysis all day long but I still wonder after 20 years how things might have been different.  Oh well.</p>

<p>Jon's contest is an excellent opportunity to share best practices.  Please participate if you can.</p>   
      ]]></content>
    </entry>

    <entry>
      <title>Compound Annual Growth Rate Formula</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/compound_annual_growth_rate_formula/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.94</id>
      <published>2008-06-07T09:00:00Z</published>
      <updated>2008-06-07T10:20:07Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="General"
        scheme="http://www.cellmatrix.net/index.php/site/category/General/"
        label="General" />
      <content type="html"><![CDATA[
        <p>I've been away for a month and during that time the skyrocketing price of gas has received a lot of press.  Having worked in the oil industry summers while in school, I've always found it interesting how people react to the price of gas.  Until recently my thought had been that the price of gas had not kept up with inflation and the we in the U.S. should be probably be paying four to five dollars per gallon.  However, I've never thought to prove my theory out until now.</p>

<p>In an effort to track what the price of gas has done over time, I first visited the U.S. Department of Labor's <a href="http://www.bls.gov/cpi/" title="Consumer Price Index">Consumer Price Index</a> page.  The first area of information I wanted to find was the <a href="ftp://ftp.bls.gov/pub/special.requests/cpi/cpiai.txt" title="Consumer Price Index for All Urban Consumers">Consumer Price Index for All Urban Consumers</a>.  Using January 1984 as the base, I set the base CPI for my analysis at 101.90.  I then copied each monthly value from January 1984 to April 2008 into an Excel spreadsheet.  Next, I retreived the average price per gallon values for <a href="http://data.bls.gov/cgi-bin/surveymost?ap" title=" regular unleaded gasoline">regular unleaded gasoline</a> for the same time period.  To get an inflation adjusted price for gasoline, I multiplied the base price of gas (January 1984) by the CPI for the month.  The results appear in the chart below.  The year is on the X axis and the price per gallon of regular unleaded is on the Y axis.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008060701.GIF" style="border: 0;" alt="image" width="426" height="266" />
</div>

<p>The chart shows that the price per gallon of regular unleaded remained essentially flat from 1984 to 2000.  After a small bubble that occurred from 2000 to 2002, the price starts to increase at a pace of over 20% per year.  The 20% figure is calculated using the Compound Annual Growth Rate formula.  The formula is:<p>

<div class="codeblock"><code>
<span style="color: #007700">( </span><span style="color: #0000BB">Future Value </span><span style="color: #007700">/ </span><span style="color: #0000BB">Present Value </span><span style="color: #007700">) ^ ( </span><span style="color: #0000BB">1 </span><span style="color: #007700">/ </span><span style="color: #0000BB">Number of Periods </span><span style="color: #007700">) - </span><span style="color: #0000BB">1</span>
</code></div> 

<p>Excel's XIRR function can also be used to perform this calculation.  The Analysis Toolpak must be installed for this function to work.<p>

<p>In January of 2002, the price of regular unleaded averaged $1.14.  Five years later the price averaged $3.05.  Using the formula above to calculate the compounded annual growth rate . . .</p>

<div class="codeblock"><code>
<span style="color: #007700">( $</span><span style="color: #0000BB">3.05 </span><span style="color: #007700">/ $</span><span style="color: #0000BB">1.14 </span><span style="color: #007700">) ^ ( </span><span style="color: #0000BB">1 </span><span style="color: #007700">/ </span><span style="color: #0000BB">5 </span><span style="color: #007700">) - </span><span style="color: #0000BB">1 </span><span style="color: #007700">= </span><span style="color: #0000BB">21.75</span><span style="color: #007700">%</span>
</code></div>

<p>Using 1984 as the base, the chart shows that the average price of unleaded gas exceeds the inflation adjusted price somewhere around 2006 to 2007.  Unfortunately all of the growth has taken place in the last five years and it really doesn't start to stand out until 2004 - 2005.  Based on inflation, it looks like my $4 to $5 price target may have been too high.  Or, maybe $4 to $5 is the reality and the CPI is not reflecting that growth yet because the overall economy hasn't fully priced in current gas costs.</p>  

<p>On another note, in the summer of 2004 I parked my truck and started to ride my motorcycle everywhere.  I like to tell people that I anticipated the rising price of gas but the truth is that I just wanted to start riding a motorcycle instead of driving a car.  Co-workers like to tell me "oh, you must be saving a lot of money by riding a motorcycle to work every day instead of driving a car".  Although the bike does get between 40 to 50 mpg depending on driving conditions, I'm not sure that I'm really saving any money.  What they don't realize is that I purchased a new motorcycle as opposed to driving a truck that was paid for.  I recently figured I would have to ride the motorcycle for about ten years if I thought I was going to break even based on gas prices.  I may be saving gas but I'm not saving any money, at this point anyway.</p> 

     
      ]]></content>
    </entry>

    <entry>
      <title>XY&#45;Bar Combination Chart</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/xy_bar_combination_chart/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.93</id>
      <published>2008-04-28T11:32:00Z</published>
      <updated>2008-04-28T13:10:22Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Charts"
        scheme="http://www.cellmatrix.net/index.php/site/category/Charts/"
        label="Charts" />
      <content type="html"><![CDATA[
        <p>Recently I've had to create a series of Bar charts that incorporate points that allow additional data labels.  I've created these points by building in an XY scatter chart into the Bar chart.  The additional data labels are tied to the XY points using a tool such as John Walkenbach's <a href="http://www.j-walk.com/ss/excel/files/charttools.htm" title="J-Walk Chart Tools">J-Walk Chart Tools</a> or Rob Bovey's <a href="http://www.appspro.com/Utilities/ChartLabeler.htm" title="XY Chart Labeler">XY Chart Labeler</a>.</p>

<p>An example of one of these charts, less data labels, looks like this:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008042801.GIF" style="border: 0;" alt="image" width="426" height="253" />
</div> 

<p>The person who requested the chart wanted each XY point to be visible as well as vertically centered within each bar.  To do so, I started by setting the gap width to 100%.  Next, a calculation creates the Y values of the XY points as illustrated below.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008042802.gif" style="border: 0;" alt="image" width="407" height="379" />
</div>

<p>The calculation starts with the source data for the bar chart which is contained in the range B4:E8.  There are four categories and three series within each category.  I've entered those numbers into the yellow highlighted cells D19 and D20.  The calculation of the lowest Y point on the XY chart vertical axis is contained in cell D23.  The calculation is:</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">D20</span><span style="color: #007700">/(</span><span style="color: #0000BB">D20</span><span style="color: #007700">+</span><span style="color: #0000BB">1</span><span style="color: #007700">)</span>
</code></div> 

<p>Once this calculation is done, the results can be applied to all of the Y values of the XY chart.  The XY chart source is contained in the range C11:H15.  The results of the calculation above are linked to cell D12.  Cell D13 adds the series per category value to the results in C12.  The formula in D13 is:</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">D12</span><span style="color: #007700">+</span><span style="color: #0000BB">$D</span><span style="color: #007700">$</span><span style="color: #0000BB">20</span>
</code></div> 

<p>Cell F12 adds the series per category value to the results in C12.  The formula in F12 is:</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">D12</span><span style="color: #007700">+</span><span style="color: #0000BB">$D</span><span style="color: #007700">$</span><span style="color: #0000BB">23</span>
</code></div> 

<p>Finally, the maximum value of the secondary axis is simply the number of categories multiplied by the series per category.  The formula in cell D24 is:</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">D19</span><span style="color: #007700">*</span><span style="color: #0000BB">D20</span>
</code></div> 

<p>The VBA procedure below attempts to quickly build this chart based on the template above.  Please note that it references the color palette that I currently use - your colors may be different.  At this point the output produces the following:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008042803.GIF" style="border: 0;" alt="image" width="426" height="253" />
</div>

<p>Given time the procedure could be written to complete the formatting.  It could also be modified to automatically accept a reasonable number of changing categories and series, use a custom color palette, and allow more efficient range references.</p>

<div class="codeblock"><code>
<span style="color: #0000BB">Option Explicit<br /><br />Sub BuildChart</span><span style="color: #007700">()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Application</span><span style="color: #007700">.</span><span style="color: #0000BB">ScreenUpdating </span><span style="color: #007700">= </span><span style="color: #0000BB">False<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;Dim XVals </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Srs1 </span><span style="color: #007700">As </span><span style="color: #0000BB">String<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Srs2 </span><span style="color: #007700">As </span><span style="color: #0000BB">String<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Srs3 </span><span style="color: #007700">As </span><span style="color: #0000BB">String<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;Set XVals </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"B5:B8"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Srs1 </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"C4"</span><span style="color: #007700">).</span><span style="color: #0000BB">Value<br />&nbsp;&nbsp;&nbsp;&nbsp;Srs2 </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"D4"</span><span style="color: #007700">).</span><span style="color: #0000BB">Value<br />&nbsp;&nbsp;&nbsp;&nbsp;Srs3 </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"E4"</span><span style="color: #007700">).</span><span style="color: #0000BB">Value<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;Charts</span><span style="color: #007700">.</span><span style="color: #0000BB">Add<br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Location Where</span><span style="color: #007700">:=</span><span style="color: #0000BB">xlLocationAsObject</span><span style="color: #007700">, </span><span style="color: #0000BB">Name</span><span style="color: #007700">:=</span><span style="color: #DD0000">"Sheet1"<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">With ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">SeriesCollection</span><span style="color: #007700">.</span><span style="color: #0000BB">NewSeries<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Name </span><span style="color: #007700">= </span><span style="color: #0000BB">Srs1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">ChartType </span><span style="color: #007700">= </span><span style="color: #0000BB">xlBarClustered<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">XValues </span><span style="color: #007700">= </span><span style="color: #0000BB">XVals<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Values </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"C5:C8"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">Interior</span><span style="color: #007700">.</span><span style="color: #0000BB">ColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">22<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Border</span><span style="color: #007700">.</span><span style="color: #0000BB">LineStyle </span><span style="color: #007700">= </span><span style="color: #0000BB">xlNone<br />&nbsp;&nbsp;&nbsp;&nbsp;End With<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;With ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">SeriesCollection</span><span style="color: #007700">.</span><span style="color: #0000BB">NewSeries<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Name </span><span style="color: #007700">= </span><span style="color: #0000BB">Srs2<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">ChartType </span><span style="color: #007700">= </span><span style="color: #0000BB">xlBarClustered<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">XValues </span><span style="color: #007700">= </span><span style="color: #0000BB">XVals<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Values </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"D5:D8"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">Interior</span><span style="color: #007700">.</span><span style="color: #0000BB">ColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">35<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Border</span><span style="color: #007700">.</span><span style="color: #0000BB">LineStyle </span><span style="color: #007700">= </span><span style="color: #0000BB">xlNone<br />&nbsp;&nbsp;&nbsp;&nbsp;End With<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;With ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">SeriesCollection</span><span style="color: #007700">.</span><span style="color: #0000BB">NewSeries<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Name </span><span style="color: #007700">= </span><span style="color: #0000BB">Srs3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">ChartType </span><span style="color: #007700">= </span><span style="color: #0000BB">xlBarClustered<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">XValues </span><span style="color: #007700">= </span><span style="color: #0000BB">XVals<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Values </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"E5:E8"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">Interior</span><span style="color: #007700">.</span><span style="color: #0000BB">ColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">24<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Border</span><span style="color: #007700">.</span><span style="color: #0000BB">LineStyle </span><span style="color: #007700">= </span><span style="color: #0000BB">xlNone<br />&nbsp;&nbsp;&nbsp;&nbsp;End With<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;With ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">SeriesCollection</span><span style="color: #007700">.</span><span style="color: #0000BB">NewSeries<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Name </span><span style="color: #007700">= </span><span style="color: #0000BB">Srs1 </span><span style="color: #007700">&amp; </span><span style="color: #DD0000">"_XY"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">ChartType </span><span style="color: #007700">= </span><span style="color: #0000BB">xlXYScatter<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">XValues </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"C12:C15"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">Values </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"D12:D15"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">MarkerSize </span><span style="color: #007700">= </span><span style="color: #0000BB">3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerStyle </span><span style="color: #007700">= </span><span style="color: #0000BB">xlDiamond<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerBackgroundColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerForegroundColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">3<br />&nbsp;&nbsp;&nbsp;&nbsp;End With<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;With ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">SeriesCollection</span><span style="color: #007700">.</span><span style="color: #0000BB">NewSeries<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Name </span><span style="color: #007700">= </span><span style="color: #0000BB">Srs2 </span><span style="color: #007700">&amp; </span><span style="color: #DD0000">"_XY"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">ChartType </span><span style="color: #007700">= </span><span style="color: #0000BB">xlXYScatter<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">XValues </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"E12:E15"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">Values </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"F12:F15"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">MarkerSize </span><span style="color: #007700">= </span><span style="color: #0000BB">3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerStyle </span><span style="color: #007700">= </span><span style="color: #0000BB">xlDiamond<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerBackgroundColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">10<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerForegroundColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">10<br />&nbsp;&nbsp;&nbsp;&nbsp;End With<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;With ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">SeriesCollection</span><span style="color: #007700">.</span><span style="color: #0000BB">NewSeries<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">Name </span><span style="color: #007700">= </span><span style="color: #0000BB">Srs3 </span><span style="color: #007700">&amp; </span><span style="color: #DD0000">"_XY"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">ChartType </span><span style="color: #007700">= </span><span style="color: #0000BB">xlXYScatter<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">XValues </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"G12:G15"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">Values </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Sheet1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"H12:H15"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">MarkerSize </span><span style="color: #007700">= </span><span style="color: #0000BB">3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerStyle </span><span style="color: #007700">= </span><span style="color: #0000BB">xlDiamond<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerBackgroundColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">5<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">MarkerForegroundColorIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">5<br />&nbsp;&nbsp;&nbsp;&nbsp;End With<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">ChartGroups</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">).</span><span style="color: #0000BB">GapWidth </span><span style="color: #007700">= </span><span style="color: #0000BB">100<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlCategory</span><span style="color: #007700">, </span><span style="color: #0000BB">xlSecondary</span><span style="color: #007700">).</span><span style="color: #0000BB">MaximumScale </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"D25"</span><span style="color: #007700">).</span><span style="color: #0000BB">Value<br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlCategory</span><span style="color: #007700">, </span><span style="color: #0000BB">xlSecondary</span><span style="color: #007700">).</span><span style="color: #0000BB">MinimumScale </span><span style="color: #007700">= </span><span style="color: #0000BB">0<br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlCategory</span><span style="color: #007700">, </span><span style="color: #0000BB">xlSecondary</span><span style="color: #007700">).</span><span style="color: #0000BB">MajorUnit </span><span style="color: #007700">= </span><span style="color: #0000BB">1<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlValue</span><span style="color: #007700">).</span><span style="color: #0000BB">MaximumScale </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"D25"</span><span style="color: #007700">).</span><span style="color: #0000BB">Value<br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlValue</span><span style="color: #007700">).</span><span style="color: #0000BB">MinimumScale </span><span style="color: #007700">= </span><span style="color: #0000BB">0<br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlValue</span><span style="color: #007700">).</span><span style="color: #0000BB">MajorUnit </span><span style="color: #007700">= </span><span style="color: #0000BB">1<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlValue</span><span style="color: #007700">, </span><span style="color: #0000BB">xlSecondary</span><span style="color: #007700">).</span><span style="color: #0000BB">MaximumScale </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"D24"</span><span style="color: #007700">).</span><span style="color: #0000BB">Value<br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Axes</span><span style="color: #007700">(</span><span style="color: #0000BB">xlValue</span><span style="color: #007700">, </span><span style="color: #0000BB">xlSecondary</span><span style="color: #007700">).</span><span style="color: #0000BB">TickLabels</span><span style="color: #007700">.</span><span style="color: #0000BB">NumberFormat </span><span style="color: #007700">= </span><span style="color: #DD0000">"#,##0"<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Parent</span><span style="color: #007700">.</span><span style="color: #0000BB">Height </span><span style="color: #007700">= </span><span style="color: #0000BB">189.75<br />&nbsp;&nbsp;&nbsp;&nbsp;ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Parent</span><span style="color: #007700">.</span><span style="color: #0000BB">Width </span><span style="color: #007700">= </span><span style="color: #0000BB">319.5<br /><br />End Sub</span>
</code></div> 


 
      ]]></content>
    </entry>

    <entry>
      <title>Around the Web 2</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/around_the_web_2/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.92</id>
      <published>2008-04-20T00:30:00Z</published>
      <updated>2008-04-20T00:34:53Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Around the Web"
        scheme="http://www.cellmatrix.net/index.php/site/category/around_the_web/"
        label="Around the Web" />
      <content type="html"><![CDATA[
        <p>Below are interesting items from around the web:</p>

<p>It's that time to update the annual and five-year financial forecasting model that I use at work.  The model relies heavily on linear regression techniques to perform the forecasts.  For reference, Kelly O'Day has an excellent writeup on his <a href="http://processtrends.com" title="Process Trends">Process Trends</a> site titled <a href="http://processtrends.com/toc_trend_analysis_with_Excel.htm" title="Trend Analysis with Excel">Trend Analysis with Excel</a>.</p>

<p>In <a href="http://peltiertech.com/WordPress/2008/04/18/a-belated-review-of-excel-2007/" title="A Belated Review of Excel 2007">A Belated Review of Excel 2007</a>, Jon Peltier describes his experiences with the latest release.  Although I have Excel 2003 and 2007, I tend to do almost all of my work in 2003 more than likely because that's also what we use at work.  However, that will probably change soon as the healthcare system that I work for recently purchased licenses for Office 2007 to support the local staff.</p>

<p>In September of 2005, David Gainer wrote in the <a href="http://blogs.msdn.com/excel/archive/2005/09/28/475041.aspx" title="The Excel Team Blog">The Excel Team Blog</a> that Excel 2007 "made huge improvements to our charting engine for great-looking charts in Excel and across Office" and that Microsoft had "reworked the chart UI to make creating and working with charts much simpler and easier".  Fast-forward to 2008 . . . I wonder what the general opinion of end-users and developers is now regarding functionality and features?</p> 

<p>Microsoft's <a href="http://msdn2.microsoft.com/en-us/office/aa905530.aspx" title="Office Fluent User Interface Developer Portal">Office Fluent User Interface Developer Portal</a> contains a series of resources for customizing the Office 2007 ribbon.</p>

<p>This site uses a combination of CSS and HTML tables.  One of my favorite references for formatting tables in CSS is Robert Denton's <a href="http://robertdenton.org/reference/css-tables-tutorial.html" title="CSS Tables Tutorial">CSS Tables Tutorial</a>.  Although the last update to this site was in 2002, adapting the CSS examples to XHTML standards was very easy with the help of the <a href="http://validator.w3.org/" title="WC3 Markup Validator">WC3 Validator</a>.  TechRepublic also has a nice writeup titled <a href="http://articles.techrepublic.com.com/5100-22-5244791.html" title="Why CSS Styling is for Tables Too">Why CSS Styling is for Tables Too</a>.</p>

<p><a href="http://www.mandarindesign.com/" title="Mandarin Design">Mandarin Design</a> is one of my favorite resources for general website and blog design.  The site features a variety of formatting techniques for setting up multiple columns, floating images, etc.  Unfortunately the author passed away sometime back so the site is no longer actively updated.  However, it is still online which is great for novice users like myself.</p>
 
      ]]></content>
    </entry>

    <entry>
      <title>Pivot Table Difference Between Columns</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/pivot_table_difference_between_columns/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.91</id>
      <published>2008-04-17T04:12:00Z</published>
      <updated>2008-04-17T05:05:05Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Pivot Tables"
        scheme="http://www.cellmatrix.net/index.php/site/category/pivot_tables/"
        label="Pivot Tables" />
      <content type="html"><![CDATA[
        <p>When I most need it, I always seem to forget how to compute the difference between two pivot table columns.  So, it's about time to put it in writing.  Assume the following data:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008041601.gif" style="border: 0;" alt="image" width="235" height="155" />
</div>

<p>Create a simple pivot table with the years as columns and the areas as rows.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008041602.gif" style="border: 0;" alt="image" width="371" height="141" />
</div>

<p>Next, eliminate the row totals.  To do so, right-click any cell within the pivot table and go to Table Options.  Deselect "Grand total for rows" from the format options area of the Table Options dialog box.</p>

<p>At this point it's time to create a calculated item that subtracts the 2008 data from the 2007 data.  Right-click on the year (cell B2) and select Show Pivot Table Toolbar.  In the Pivot Table toolbar, choose Formulas -> Calculated Item.  The following dialog box will appear:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008041603.gif" style="border: 0;" alt="image" width="414" height="311" />
</div>   

<p>Add the formula for the calculated item as shown below:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008041604.gif" style="border: 0;" alt="image" width="414" height="311" />
</div>

<p>To make all of the accountants happy, we need to make the most recent year appear as the first column of the table.  To do so, right-click within the column titles (2008, 2007, or Difference) -> Order.  You can then move the any of the columns to the right or left to achieve the desired look.</p>

<p>The end-result looks like this:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008041605.gif" style="border: 0;" alt="image" width="434" height="141" />
</div>




 
      ]]></content>
    </entry>

    <entry>
      <title>Percent Change Error Trap</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/percent_change_error_trap/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.88</id>
      <published>2008-04-12T06:00:00Z</published>
      <updated>2008-04-17T03:00:03Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Formulas"
        scheme="http://www.cellmatrix.net/index.php/site/category/Formulas/"
        label="Formulas" />
      <content type="html"><![CDATA[
        <p>To keep the percent change formula from returning errors and/or extreme values, consider a nested IF statement to trap errors or values that fall outside of a certain range.  In the example below, "n/a" refers to "not applicable".  Errors have been trapped in lines one through three.  In line four, the formula returns "n/a" because the absolute value of the change is greater than 200%.  This logic is written into the formula to prevent it from returning exteme values.</p>  

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008041201.gif" style="border: 0;" alt="image" width="418" height="197" />
</div>

<p>The formula in G4 is below.  It is copied from cell G4 into cells G6, G8, G10, and G12.</p>

<div class="codeblock"><code>
<span style="color: #007700">=IF(</span><span style="color: #0000BB">ISERROR</span><span style="color: #007700">((</span><span style="color: #0000BB">E12</span><span style="color: #007700">-</span><span style="color: #0000BB">F12</span><span style="color: #007700">)/</span><span style="color: #0000BB">ABS</span><span style="color: #007700">(</span><span style="color: #0000BB">F12</span><span style="color: #007700">)),</span><span style="color: #DD0000">"n/a"</span><span style="color: #007700">,IF(</span><span style="color: #0000BB">ABS</span><span style="color: #007700">((</span><span style="color: #0000BB">E12</span><span style="color: #007700">-</span><span style="color: #0000BB">F12</span><span style="color: #007700">)/</span><span style="color: #0000BB">ABS</span><span style="color: #007700">(</span><span style="color: #0000BB">F12</span><span style="color: #007700">))&gt;</span><span style="color: #0000BB">2</span><span style="color: #007700">,</span><span style="color: #DD0000">"n/a"</span><span style="color: #007700">,IF((</span><span style="color: #0000BB">E12</span><span style="color: #007700">-</span><span style="color: #0000BB">F12</span><span style="color: #007700">)/</span><span style="color: #0000BB">ABS</span><span style="color: #007700">(</span><span style="color: #0000BB">F12</span><span style="color: #007700">)=-</span><span style="color: #0000BB">1</span><span style="color: #007700">,</span><span style="color: #DD0000">"n/a"</span><span style="color: #007700">,(</span><span style="color: #0000BB">E12</span><span style="color: #007700">-</span><span style="color: #0000BB">F12</span><span style="color: #007700">)/</span><span style="color: #0000BB">ABS</span><span style="color: #007700">(</span><span style="color: #0000BB">F12</span><span style="color: #007700">))))</span>
</code></div>

 
      ]]></content>
    </entry>

    <entry>
      <title>Simple Goal Seek Procedure</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/simple_goal_seek_procedure/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.87</id>
      <published>2008-04-06T11:59:00Z</published>
      <updated>2008-04-06T13:43:05Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="VBA"
        scheme="http://www.cellmatrix.net/index.php/site/category/VBA/"
        label="VBA" />
      <content type="html"><![CDATA[
        <p>Unfortunately Excel's goal seeking feature forces you to hand-enter a value into the "To value" field of the input box.  You can't directly tie this input to a cell like you can with the "Set cell" and "By changing cell" inputs (see the screenshot below).</p>  
 
<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008040601.gif" style="border: 0;" alt="image" width="227" height="140" />
</div>

<p>This can make things difficult especially if you're trying to seek very large values or values that that are carried out to many decimal points.</p>   

<p>The following procedure allows you to get around this limitation.  First, enter the cell addresses for the variables called Rng1, Rng2, and Rng3.  Note that a formula must appear in Rng1 and a value must be entered into Rng3.  Next, run the procedure.</p> 

<div class="codeblock"><code>
<span style="color: #0000BB">Sub GoalSeek</span><span style="color: #007700">()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Dim Rng1 </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Rng2 </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Rng3 </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo errHandler</span><span style="color: #007700">:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'Set the value in this cell<br />&nbsp;&nbsp;&nbsp;&nbsp;Set Rng1 = ActiveSheet.Range("C4")<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;'</span><span style="color: #0000BB">Equal to the value in this cell<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'Note:&nbsp;&nbsp;This cell must contain a formula<br />&nbsp;&nbsp;&nbsp;&nbsp;Set Rng2 = ActiveSheet.Range("C7")<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;'</span><span style="color: #0000BB">By changing the value in this cell<br />&nbsp;&nbsp;&nbsp;&nbsp;Set Rng3 </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveSheet</span><span style="color: #007700">.</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"C2"</span><span style="color: #007700">)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;If </span><span style="color: #0000BB">Rng1</span><span style="color: #007700">.</span><span style="color: #0000BB">HasFormula </span><span style="color: #007700">= </span><span style="color: #0000BB">True Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">If </span><span style="color: #0000BB">IsNumeric</span><span style="color: #007700">(</span><span style="color: #0000BB">Rng3</span><span style="color: #007700">) = </span><span style="color: #0000BB">True Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rng1</span><span style="color: #007700">.</span><span style="color: #0000BB">GoalSeek Goal</span><span style="color: #007700">:=</span><span style="color: #0000BB">Rng2</span><span style="color: #007700">, </span><span style="color: #0000BB">ChangingCell</span><span style="color: #007700">:=</span><span style="color: #0000BB">Rng3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End </span><span style="color: #007700">If<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">End </span><span style="color: #007700">If<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;Exit </span><span style="color: #0000BB">Sub<br /><br />errHandler</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">MsgBox </span><span style="color: #DD0000">"Procedure failed - please check inputs."<br /><br /></span><span style="color: #0000BB">End Sub</span>
</code></div>

 
      ]]></content>
    </entry>

    <entry>
      <title>Interpretation of Percent Change</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/interpretation_of_percent_change/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.86</id>
      <published>2008-04-03T10:51:01Z</published>
      <updated>2008-04-03T12:12:23Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Formulas"
        scheme="http://www.cellmatrix.net/index.php/site/category/Formulas/"
        label="Formulas" />
      <content type="html"><![CDATA[
        <p>Over time I've found that the interpretation of percent change is one of the most simple and misunderstood calculations in finance.  As an example, take the following data:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008040301.gif" style="border: 0;" alt="image" width="223" height="197" />
</div>

<p>The formula in cell C3 is</p>

<div class="codeblock"><code>
<span style="color: #007700">=(</span><span style="color: #0000BB">B3</span><span style="color: #007700">-</span><span style="color: #0000BB">B4</span><span style="color: #007700">)/</span><span style="color: #0000BB">B4</span>
</code></div>

<p>This is the formula that I've found most people use.  The formula works great when you're comparing positive numbers.  However, a problem occurs when you bring in the negatives.  Looking at cell C11, is it correct to say that the increase from -45 to -35 is -22.2%?  If -35 is a larger number than -45, how can the increase be a negative?</p>

<p>If you look at all numbers, positive and negative, as being on a single scale the calculation is easier to see.  Now we'll take the same data above and apply a slightly different formula:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008040302.gif" style="border: 0;" alt="image" width="223" height="197" />
</div>

<p>The formula in cell C3 is</p>

<div class="codeblock"><code>
<span style="color: #007700">=(</span><span style="color: #0000BB">B3</span><span style="color: #007700">-</span><span style="color: #0000BB">B4</span><span style="color: #007700">)/(</span><span style="color: #0000BB">ABS</span><span style="color: #007700">)</span><span style="color: #0000BB">B4</span>
</code></div>

<p>When you look at column C, all of the percent increases are positive percentages.  Likewise, when you look at column D all of the percent decreases are negative percentages.  Positive percentages correspond to moving up the number scale and negative percentages correspond to moving down the number scale.</p>

<p>To conclude, the formula that includes Excel's ABS function is the correct formula.  The ABS function insures that the denominator in the formula is always positive which allows the formula to return the correct percentage change.  If you use this formula and think of the number scale, you'll never have to worry about the calculation of percent change and / or how to explain it to those that may not understand how to interpret it.</p>

 
      ]]></content>
    </entry>

    <entry>
      <title>Secondary Axes in Charts Discussion</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/secondary_axes_in_charts_discussion/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.84</id>
      <published>2008-03-31T03:53:00Z</published>
      <updated>2008-04-01T06:12:03Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Charts"
        scheme="http://www.cellmatrix.net/index.php/site/category/Charts/"
        label="Charts" />
      <content type="html"><![CDATA[
        <p>Recently the topic of <a href="http://peltiertech.com/WordPress/2008/03/25/secondary-axes-in-charts-2/" title="primary and secondary axis scales">primary and secondary axis scales</a> was discussed at the <a href="http://peltiertech.com/WordPress/" title="PTS Blog">PTS Blog</a>.  The discussion starts with a reference to Stephen Few's March 2008 Visual Business Intelligence Newsletter titled <a href="http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf" title="Dual-Scaled Axis in Graphs - Are They Ever the Best Solution ">Dual-Scaled Axis in Graphs - Are They Ever the Best Solution </a>.  Stephen starts his article by concluding that He then goes on to cite a series of examples.  Finally, at the end of his article he states that "I certainly cannot conclude, once and for all, that graphs with dual-scaled axes are never useful; only that I cannot think of a situation that warrants them in light of other, better solutions. I invite you to propose viable exceptions, which I will welcome with open arms."</p>

<p>From a healthcare finance perspecitive, it has been my experience that these charts are great tools for those who know how to build them and for those audiences that know how to interpret the underlying data.  Below are several comments I have concerning Stephen's article:</p>

<p><b>Comment #1</b> - It's not necessarily the chart with two axes that's bad, it's the data behind it.  In the newsletter, most of Stephen's graphs illustrate the relationship between revenue and units sold.  I would argue that is comparison is flawed from the beginning and, as such, this type of chart should not be used.  My reasoning is that, although it seems like the data is should be related, when you drill down into the data you might find out that the correlation is not as close as you might have thought.  Depending on the data:</p>

<ul>
<li>What defines a unit?</li>
<li>Are the units the same unit each quarter or are there multiple types of units being charted as one?</li>
<li>If there are multiple units, how are the changes in volume accounted for within the sales mix?</li>
<li>Won't price increases distort the data over time?</li>
<li>How does the chart account for decreases in purchasing power over time i.e inflation over time?</li>
<li>If the data is measured by quarter and one of the quarters includes a leap year, how do you account for the extra day?</li>
</ul>

<p>In my opinion, I think an argument can be made that a dual axis chart showing revenue and units sold is probably not the the best use of a dual-axes chart.  That being said I do have to admit that I do use this type comparison at a top-level where the components of variance might be considered immaterial.  If a dual-axes chart is to be used the audience should be educated on how to interpret the underlying data and how to recognize and address possible flaws before decisions a made.</p>

<p><b>Comment #2</b> - If you are going to present a dual-axis chart, the axes need to be proportional.  That means doing the math for each axes to make sure it is in fact proportional to the other.</p>

<p><b>Comment #3</b> - As Stephen observed, line graphs are the best presentation for this type of chart.</p>

<p><b>Comment #4</b> - "I can’t think of a single case when there isn’t a better solution than a graph with a dual-scaled axis."  In my line of work, we've found that these graphs are very useful for <b>auditing calculations</b>.  For example, you are tasked with building a projection of revenue and discounts for the next year.  In a healthcare environment, revenue and discounts both contain the same components of variance i.e. work days, fee increases, volume changes, payer mix changes, and changes in service mix or acuity.  The calculations the build all of these components can get very complex.  Rather than attemping to proof each calculation that builds the projection, this chart can quickly pick up areas of possible error.</p>

<p>In the example below, it's obvious that there's problem with June calculations because the lines are not in sync for that month.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008033001.gif" style="border: 0;" alt="image" width="448" height="280" />
</div>

<p>Comparing the growth in <b>same-type volumes</b> (for example Radiology vs. Laboratory volumes) is another example.</p>

<p>To conclude, there may in fact be better charts for displaying certain types of data.  But if the audience understands the relationships between the data  I think there is a place for these charts.  And like the example above shows, there's most definitely a place for these charts when performing audits.</p>

 

 
 
      ]]></content>
    </entry>

    <entry>
      <title>Size and Export Embedded Charts as .GIF Images</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/size_and_export_embedded_charts_as_gif_images/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.83</id>
      <published>2008-03-24T04:06:00Z</published>
      <updated>2008-04-05T12:36:04Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="VBA"
        scheme="http://www.cellmatrix.net/index.php/site/category/VBA/"
        label="VBA" />
      <content type="html"><![CDATA[
        <p>To add images of embedded charts to this weblog, I use the VBA procedure below.  To run the procedure, first make sure the specifications are correct.  You can make changes to the chart height, width, file name, and file path.  When all of the inputs are correct, click on (activate) the embedded chart and run the macro.</p>

<div class="codeblock"><code>
<span style="color: #0000BB">Sub ExportChart</span><span style="color: #007700">()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Dim Cht </span><span style="color: #007700">As </span><span style="color: #0000BB">ChartObject<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Path </span><span style="color: #007700">As </span><span style="color: #0000BB">String<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim FileName </span><span style="color: #007700">As </span><span style="color: #0000BB">String<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Set Cht </span><span style="color: #007700">= </span><span style="color: #0000BB">ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Parent<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;Cht</span><span style="color: #007700">.</span><span style="color: #0000BB">Height </span><span style="color: #007700">= </span><span style="color: #0000BB">210<br />&nbsp;&nbsp;&nbsp;&nbsp;Cht</span><span style="color: #007700">.</span><span style="color: #0000BB">Width </span><span style="color: #007700">= </span><span style="color: #0000BB">336<br />&nbsp;&nbsp;&nbsp;&nbsp;FileName </span><span style="color: #007700">= </span><span style="color: #DD0000">"2008032301.gif"<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Path </span><span style="color: #007700">= </span><span style="color: #DD0000">"C:\Program Files\"<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ActiveChart</span><span style="color: #007700">.</span><span style="color: #0000BB">Export Path </span><span style="color: #007700">&amp; </span><span style="color: #0000BB">FileName<br /><br />End Sub</span>
</code></div>

<p>Please note that the height and width are not really needed.  I've added this code only because I like to make sure all of the charts are exactly the same size.</p>

 
      ]]></content>
    </entry>

    <entry>
      <title>Comparing Revenue Growth &#45; Gross vs. Net</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/comparing_revenue_growth_gross_vs_net/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.82</id>
      <published>2008-03-23T03:50:01Z</published>
      <updated>2008-04-03T12:14:26Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Charts"
        scheme="http://www.cellmatrix.net/index.php/site/category/Charts/"
        label="Charts" />
      <content type="html"><![CDATA[
        <p>Gross revenue can be simply defined as charges billed.  Net revenue, on the other hand, is more reflective of the revenue you expect to actually receive.  In a healthcare environment, the spread between gross and net revenue can be fairly significant depending on who pays the bill.</p>

<p>A bar chart provides a simple visual comparison of gross vs. net revenue.  Although the stacked bar chart initially seemed like the best choice to me, over time I've found that a regular bar chart with the bar overlap set to 100% works well too.</p>

<p>In this example, the goal is to chart the change in gross and net revenue in the Commercial / Contract and Government areas for the annual periods 2006 and 2007.  Below is how I've set up the data:</p> 

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008032201.gif" style="border: 0;" alt="image" width="465" height="56" />
</div>

<p>The Chart Wizard produces the following:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008032202.GIF" style="border: 0;" alt="image" width="448" height="280" />
</div>

<p>The next task is to overlay the bars by setting the overlap to 100%.  To do so, go to the Format Data Series dialog box - Options tab and change the overlap to 100%.</p> 

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008032203.gif" style="border: 0;" alt="image" width="461" height="399" />
</div>

<p>Finally, with a series of minor formatting changes the chart looks like this:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008032204.GIF" style="border: 0;" alt="image" width="448" height="280" />
</div>

<p>The chart shows the following:</p>

<ul>
<li>The Government area is above the blue line and the Commercial / Contract area is below the blue line.</li> 
<li>The Commercial / Contract revenue grew while the Government gross revenue showed no increase and reimbursement decreased.</li>
<li>The Commerical / Contract reimbursement is significantly higher than the Government reimbursement.  As a result, the Commercial / Contract area looks much more attractive from a financial perspective.</li>
</ul>

 
      ]]></content>
    </entry>

    <entry>
      <title>Index&#45;Match Formula</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/index_match_formula/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.81</id>
      <published>2008-03-21T06:28:00Z</published>
      <updated>2008-04-03T12:15:16Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Formulas"
        scheme="http://www.cellmatrix.net/index.php/site/category/Formulas/"
        label="Formulas" />
      <content type="html"><![CDATA[
        <p>Recently I've had to use formulas that perform left-sided lookups at work.  The combination of Index and Match in a formula will do so, but I always seem to have a hard time remembering how to build the formula.  Recently I put together this color-coded example to help:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008032001.gif" style="border: 0;" alt="image" width="247" height="211" />
</div>

<p>The formula in cell C8 looks like this:</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">INDEX</span><span style="color: #007700">(</span><span style="color: #0000BB">Range_of_Values_To_Look_Up</span><span style="color: #007700">,</span><span style="color: #0000BB">MATCH</span><span style="color: #007700">(</span><span style="color: #0000BB">Look_Up_Value</span><span style="color: #007700">,</span><span style="color: #0000BB">Range_of_Look_Up_Values</span><span style="color: #007700">,</span><span style="color: #0000BB">0</span><span style="color: #007700">),</span><span style="color: #0000BB">1</span><span style="color: #007700">)</span>
</code></div>

<p>or</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">INDEX</span><span style="color: #007700">(</span><span style="color: #0000BB">B2</span><span style="color: #007700">:</span><span style="color: #0000BB">B6</span><span style="color: #007700">,</span><span style="color: #0000BB">MATCH</span><span style="color: #007700">(</span><span style="color: #0000BB">B8</span><span style="color: #007700">,</span><span style="color: #0000BB">D2</span><span style="color: #007700">:</span><span style="color: #0000BB">D6</span><span style="color: #007700">,</span><span style="color: #0000BB">0</span><span style="color: #007700">),</span><span style="color: #0000BB">1</span><span style="color: #007700">)</span>
</code></div>

 
      ]]></content>
    </entry>

    <entry>
      <title>SUMPRODUCT Function to Drive Financial Statements</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/sumproduct_function_to_drive_financial_statements/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.80</id>
      <published>2008-03-16T05:26:00Z</published>
      <updated>2008-04-05T13:47:33Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Formulas"
        scheme="http://www.cellmatrix.net/index.php/site/category/Formulas/"
        label="Formulas" />
      <content type="html"><![CDATA[
        <p>If you need to report statistics or financial data in a standard template each month, consider using Excel as a simple database and the SUMPRODUCT function within formulas as the engine that drives the reporting.  For example, many financial reports include the following standard data elements:</p>

<ul>
<li>Current month and year-to-date results.</li>
<li>The variance of current month and year-to-date results against a plan.</li>
<li>Current month and year-to-date results measured against the same month last year and year-to-date.</li>
</ul>

<p>As soon as the data is compiled, many analysts enter the data into a spreadsheet.  They then change the formulas in the report to reference the data that needs to appear for the most current month.  Given the manual changes to formulas, the risk of error is increased.</p>

<p>Rather than recreating formula references each month, the spreadsheet can be set to work much more efficiently.  By changing the month in one cell and the year in another, the SUMPRODUCT function when used within formulas can automatically update the entire report.</p>

<p>The following example is based on two sheets in a workbook:</p>

<ul>
<li>The first sheet, called "dBase", contains the data needed to feed the report.</li>
<li>The second sheet, called "Rpt", contains the actual report.  It also contains two cells that allow the user to update the report by changing the year and the month.</li>
</ul>

<p>Beginning the example, the screenshot below is a very simple example of the data that might be needed for the typical financial statement.  The worksheet in which the data resides is called "dBase":</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008031501.gif" style="border: 0;" alt="image" width="456" height="435" />
</div>

<p>The report below contains the elements as described in the bullets above.  The worksheet in which the report resides is called "Rpt".</p>
<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008031502.gif" style="border: 0;" alt="image" width="595" height="320" />
</div> 

<p>SUMPRODUCT formulas are included in the formulas within the report.  Those formulas act as month and year-to-date lookups.</p>

<p>To build the SUMPRODUCT formulas, I've first created two named ranges.  The first named range, called "Year", covers the range B4:B29 of the dBase sheet.  The named range dialog box for the formula named "Year" looks like this:</p> 

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008031503.gif" style="border: 0;" alt="image" width="410" height="249" />
</div>
     
<p>The second named range, called "Month", covers the range C4:C29 of the dBase sheet.  The named range dialog box for the formula named "Month" looks like this:</p> 

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008031504.gif" style="border: 0;" alt="image" width="410" height="249" />
</div>

<p>Now it's time to build the report.  The SUMPRODUCT function within formulas looks up the report data based on the entries into cells E4 (the Year) and E5 (the Month).  The formulas are as follows:</p>  

<table class="sumproduct" cellspacing="0">

<tr>
<td colspan="2"><b>Monthly Financial Results - Revenue</b></td>
</tr>

<tr>
<td class="left">Cell</td>
<td class="right">Formula</td>
</tr>

<tr>
<td class="left">D16</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$D$2)*(Month=Rpt!$D$3)*(dBase!$E$4:$E$29))</td>
</tr>

<tr>
<td class="left">E16</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$D$2)*(Month=Rpt!$D$3)*(dBase!$H$4:$H$29))-D13</td>
</tr>

<tr>
<td class="left">F16</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$D$2-1)*(Month=Rpt!$D$3)*(dBase!$E$4:$E$29))</td>
</tr>

</table>

<br />

<table class="sumproduct" cellspacing="0">
<tr>
<td colspan="2"><b>Year-To-Date Financial Results - Revenue</b></td>
</tr>

<tr>
<td class="left">Cell</td>
<td class="right">Formula</td>
</tr>

<tr>
<td class="left">I16</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$D$2)*(Month&lt;=Rpt!$D$3)*(dBase!$E$4:$E$29))</td>
</tr>

<tr>
<td class="left">J16</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$D$2)*(Month&lt;=Rpt!$D$3)*(dBase!$H$4:$H$29))-I13</td>
</tr>

<tr>
<td class="left">K16</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$D$2-1)*(Month&lt;=Rpt!$D$3)*(dBase!$E$4:$E$29))</td>
</tr>

</table>

<br />

<table class="sumproduct" cellspacing="0">

<tr>
<td colspan="2"><b>Monthly Financial Results - Expense</b></td>
</tr>

<tr>
<td class="left">Cell</td>
<td class="right">Formula</td>
</tr>

<tr>
<td class="left">D18</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month=Rpt!$E$5)*(dBase!$F$4:$F$29))</td>
</tr>

<tr>
<td class="left">E18</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month=Rpt!$E$5)*(dBase!$I$4:$I$29))-D18</td>
</tr>

<tr>
<td class="left">F18</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4-1)*(Month=Rpt!$E$5)*(dBase!$F$4:$F$29))</td>
</tr>

</table>

<br />

<table class="sumproduct" cellspacing="0">

<tr>
<td colspan="2"><b>Year-To-Date Financial Results - Expense</b></td>
</tr>

<tr>
<td class="left">Cell</td>
<td class="right">Formula</td>
</tr>

<tr>
<td class="left">I18</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month&lt;=Rpt!$E$5)*(dBase!$F$4:$F$29))</td>
</tr>

<tr>
<td class="left">J18</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month&lt;=Rpt!$E$5)*(dBase!$I$4:$I$29))-I18</td>
</tr>

<tr>
<td class="left">K18</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4-1)*(Month&lt;=Rpt!$E$5)*(dBase!$F$4:$F$29))</td>
</tr>

</table>

<br />

<table class="sumproduct" cellspacing="0">

<tr>
<td colspan="2"><b>Monthly Results - FTEs</b></td>
</tr>

<tr>
<td class="left">Cell</td>
<td class="right">Formula</td>
</tr>

<tr>
<td class="left">D22</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month=Rpt!$E$5)*(dBase!$G$4:$G$29))</td>
</tr>

<tr>
<td class="left">E22</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month=Rpt!$E$5)*(dBase!$J$4:$J$29))-D22</td>
</tr>

<tr>
<td class="left">F22</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4-1)*(Month=Rpt!$E$5)*(dBase!$G$4:$G$29))</td>
</tr>

</table>

<br />

<table class="sumproduct" cellspacing="0"> 

<tr>
<td colspan="2"><b>Year-To-Date Results - FTEs</b></td>
</tr>

<tr>
<td class="left">Cell</td>
<td class="right">Formula</td>
</tr>

<tr>
<td class="left">I22</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month&lt;=Rpt!$E$5)*(dBase!$G$4:$G$29))/E5</td>
</tr>

<tr>
<td class="left">J22</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4)*(Month&lt;=Rpt!$E$5)*(dBase!$J$4:$J$29))/E5-I22</td>
</tr>

<tr>
<td class="left">K22</td>
<td class="right">=SUMPRODUCT((Year=Rpt!$E$4-1)*(Month&lt;=Rpt!$E$5)*(dBase!$G$4:$G$29))/E5</td>
</tr>

</table>

<p>To conclude, this setup allows allows the user to enter data into the dBase sheet.  The user can then automatically update the report for any month and year via inputs to the month (cell E4) and year (cell E5) inputs in the Rpt sheet.</p>
 





 
      ]]></content>
    </entry>

    <entry>
      <title>Simple Discounts Variance Analysis</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/simple_discounts_variance_analysis/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.79</id>
      <published>2008-03-11T03:19:00Z</published>
      <updated>2008-04-05T12:49:51Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="Healthcare"
        scheme="http://www.cellmatrix.net/index.php/site/category/healthcare/"
        label="Healthcare" />
      <content type="html"><![CDATA[
        <p>Below are the calculations to perform a simple variance analysis of discounts against plan in a healthcare setting.  Selected cells are color coded to make the calculation easier to understand.  The input cells reside in the range E3:F4.</p>

<p>In the example, the components of gross revenue are volume, payer mix, and acuity.  The discount rate, by definition, includes the payer mix and acuity components.  As a result, the "plug" is volume.</p> 

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008031001.gif" style="border: 0;" alt="image" width="526" height="382" />
</div>



 
      ]]></content>
    </entry>

    <entry>
      <title>Lookups and VBA Loops for Reporting</title>
      <link rel="alternate" type="text/html" href="http://www.cellmatrix.net/index.php/site/lookups_and_vba_loops_for_reporting/" />
      <id>tag:cellmatrix.net,2008:index.php/site/index/1.78</id>
      <published>2008-03-09T19:04:00Z</published>
      <updated>2008-04-05T12:50:16Z</updated>
      <author>
            <name>jfm</name>
            <email>john@cellmatrix.net</email>
                  </author>

      <category term="VBA"
        scheme="http://www.cellmatrix.net/index.php/site/category/VBA/"
        label="VBA" />
      <content type="html"><![CDATA[
        <p>Many companies produce reports at a top-level, department, division, and/or cost center level.  When Excel is used to build these reports, the normal practice seems to be to create a new sheet for each department, division, and/or cost center.  Each sheet contains the data and calculations for that area.  A single top-level reporting sheet is then created to which each department, division, and/or cost center sheet links to.  When it's all over and done the workbook can become very large, prone to error, and difficult to audit.</p> 

<p>An easier and more accurate approach is to use the combination of lookup formulas and a VBA loop to build the report.  In this example, only four sheets in the Excel file are illustrated (it could be only one if designed that way).  The first sheet, called "dBase", contains the raw data for each department, division, and/or cost center.  The second sheet, called "Calcs", contains a single set of calculations needed to build the final report.  The third sheet, called "Load", contains a summary of the data from the Calcs sheet needed for the final report.  The final sheet, called "Report", is the final report.</p>

<p>The example begins with a screenshot of the sheet called "dBase" (for database).  The "dBase" sheet contains ten departments.  The Commerical / Contract and Government volumes for each department is provided for the years 2007 and 2008.  The final report requires that you show the components of payer mix variance for each department.</p> 

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008030901.gif" style="border: 0;" alt="image" width="407" height="198" />
</div>

<p>The next screenshot shows the sheet called "Calcs".  The blue cell (C2) contains the name of the department.  The yellow cells contain lookup formulas that reference the "dbase" sheet.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008030902.gif" style="border: 0;" alt="image" width="575" height="320" />
</div>

<p>For example, the lookup formula in cell E8 is:</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">VLOOKUP</span><span style="color: #007700">(</span><span style="color: #0000BB">$C</span><span style="color: #007700">$</span><span style="color: #0000BB">2</span><span style="color: #007700">,</span><span style="color: #0000BB">dBase</span><span style="color: #007700">!</span><span style="color: #0000BB">$A</span><span style="color: #007700">$</span><span style="color: #0000BB">3</span><span style="color: #007700">:</span><span style="color: #0000BB">$E</span><span style="color: #007700">$</span><span style="color: #0000BB">12</span><span style="color: #007700">,</span><span style="color: #0000BB">2</span><span style="color: #007700">,</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)</span>
</code></div>

<p>The lookup formula in cell F8 is:</p>

<div class="codeblock"><code>
<span style="color: #007700">=</span><span style="color: #0000BB">VLOOKUP</span><span style="color: #007700">(</span><span style="color: #0000BB">$C</span><span style="color: #007700">$</span><span style="color: #0000BB">2</span><span style="color: #007700">,</span><span style="color: #0000BB">dBase</span><span style="color: #007700">!</span><span style="color: #0000BB">$A</span><span style="color: #007700">$</span><span style="color: #0000BB">3</span><span style="color: #007700">:</span><span style="color: #0000BB">$E</span><span style="color: #007700">$</span><span style="color: #0000BB">12</span><span style="color: #007700">,</span><span style="color: #0000BB">4</span><span style="color: #007700">,</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)</span>
</code></div>

<p>The next screenshot shows the sheet called "Load".  The purpose of this sheet is to reference all of the values that need to appear in the final report into one row of data.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008030903.gif" style="border: 0;" alt="image" width="491" height="72" />
</div>

<p>The data that appears in the "Load" sheet is referenced to the green cells in the "Calcs" sheet.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008030904.gif" style="border: 0;" alt="image" width="575" height="320" />
</div>

<p>Finally, a VBA procedure is run to create the report.  A loop is created that, when combined with the lookup formulas, does the following:</p>

<ul>
<li>The VBA procedure loads the name of the department into cell C2 of the "calcs" sheet.</li>
<li>The lookup formulas in the calcs sheet reference the data from the "dBase" sheet for that particular department.</li>
<li>The payer mix calculations are performed.</li>
<li>The payer mix data is referenced from the "calcs" sheet into row of data in the "Load" sheet.</li>
<li>The data from the "Load" sheet is copied as values into the final report.</li>
</ul>

<p>In this example, the procedure described above is performed ten times - once for each department as referenced in the range B8:B17 of the "Report" sheet.  The VBA code that performs the work is below:</p>

<div class="codeblock"><code>
<span style="color: #0000BB">Sub BuildReport</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Application</span><span style="color: #007700">.</span><span style="color: #0000BB">ScreenUpdating </span><span style="color: #007700">= </span><span style="color: #0000BB">False<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Rng1 </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Rng2 </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Rng3 </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br />&nbsp;&nbsp;&nbsp;&nbsp;Dim Rng4 </span><span style="color: #007700">As </span><span style="color: #0000BB">Range<br />&nbsp;&nbsp;&nbsp;&nbsp;Set Rng2 </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Calc"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"C2"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Set Rng3 </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Load"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"B3:G3"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Set Rng4 </span><span style="color: #007700">= </span><span style="color: #0000BB">Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Rpt"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"C8:H8"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;For </span><span style="color: #0000BB">Each Rng1 In Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Rpt"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"B8:B17"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Rng2</span><span style="color: #007700">.</span><span style="color: #0000BB">Value </span><span style="color: #007700">= </span><span style="color: #0000BB">Rng1</span><span style="color: #007700">.</span><span style="color: #0000BB">Value<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rng3</span><span style="color: #007700">.</span><span style="color: #0000BB">Copy<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rng4</span><span style="color: #007700">.</span><span style="color: #0000BB">PasteSpecial xlPasteValues<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set Rng4 </span><span style="color: #007700">= </span><span style="color: #0000BB">Rng4</span><span style="color: #007700">.</span><span style="color: #0000BB">Offset</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Next Rng1<br />&nbsp;&nbsp;&nbsp;&nbsp;Sheets</span><span style="color: #007700">(</span><span style="color: #DD0000">"Rpt"</span><span style="color: #007700">).</span><span style="color: #0000BB">Range</span><span style="color: #007700">(</span><span style="color: #DD0000">"A1"</span><span style="color: #007700">).</span><span style="color: #0000BB">Select<br />End Sub</span>
</code></div> 

<p>After the macro has been run, the final report looks like this:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2008030905.gif" style="border: 0;" alt="image" width="503" height="309" />
</div>

<p>The advantages of using lookup formulas and VBA loops to build the report are these:</p>

<ul>
<li>Only one set of calculations (the "Calcs" sheet) needs to be audited for accuracy.  This is especially advantageous as the number of departments, division, etc. needed on the final report grows.</li>
<li>The audit risk concerning the workbook is reduced due to less sheets and data ranges needing to be proofed.</li>
<li>The physical size of the workbook is reduced which make it easier to maintain and transfer to others via email, web, etc.</li>
<li>The VBA procedure runs fast and the report is produced almost instantaneously.</li>
</ul> 

<p>Potential disadvantages of using lookup formulas and VBA loops to build the report are these:</p>

<ul>
<li>If you need to pass the workbook on to someone that has no experience with VBA, the issue of who can maintain the workbook may come up.</li>
<li>If your manager is clueless when it comes to lookups or VBA, he or she may prefer the "many sheets and calculations" approach so they can understand it (runs hand-in-hand with the first bullet).</li>
</ul> 



 
      ]]></content>
    </entry>


</feed>