<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Number Cruncher</title>
	<atom:link href="http://excelicious.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://excelicious.wordpress.com</link>
	<description>Excel, VBA, SAS, Python and more...</description>
	<lastBuildDate>Tue, 24 Jan 2012 09:12:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='excelicious.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Number Cruncher</title>
		<link>http://excelicious.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://excelicious.wordpress.com/osd.xml" title="Number Cruncher" />
	<atom:link rel='hub' href='http://excelicious.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The Five Reasons Google Docs Is Not Ready To Replace Excel</title>
		<link>http://excelicious.wordpress.com/2012/01/24/the-five-reasons-google-docs-is-not-ready-to-replace-excel/</link>
		<comments>http://excelicious.wordpress.com/2012/01/24/the-five-reasons-google-docs-is-not-ready-to-replace-excel/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 09:12:00 +0000</pubDate>
		<dc:creator>geoffness</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Google Docs]]></category>

		<guid isPermaLink="false">http://excelicious.wordpress.com/?p=687</guid>
		<description><![CDATA[Today&#8217;s post is from guest contributor Olivia Lennox. Not too long after the initial excitement of having an application that looks exactly as a spreadsheet is meant to open up in seconds within your browser, Google Docs starts to let you down. Everything from performance on large sheets to the presentation of data is substandard [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=687&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Today&#8217;s post is from guest contributor Olivia Lennox.</em></p>
<p>Not too long after the initial excitement of having an application that looks exactly as a spreadsheet is meant to open up in seconds within your browser, Google Docs starts to let you down. Everything from performance on large sheets to the presentation of data is substandard when compared to even the Excel that ships with the 2003 version of Microsoft Office.</p>
<p>Here are the five main areas Google need to tackle before power spreadsheet users can even think about moving from Excel.</p>
<p><strong>1. Graphical Presentation Of Data</strong></p>
<p>One of the first tasks we attempted to replicate was to store and present some stock market performance data from an <a href="http://www.money.co.uk/share-dealing.htm">online share dealing</a> account. To be fair to Google Docs Spreadsheet getting used to entering data was simple and the chart was quickly on it’s own sheet after clicking the add chart button and choosing a few options.</p>
<p>Here was where the vast power of Excel that we take for granted was obviously lacking. How about adding trend lines to scatter charts? This seems currently to be an either/or only feature in Google Docs which is disappointing. In fact only a limited amount of customization is possible at all in the Graphing function. The end result of this test was a graph with the correct headings, colours and lines on Excel and a poor compromise of one line, and unwanted colour and style in Google Docs.</p>
<p>With Excel hardly at the zenith of the data presentation world (some apps like <a href="http://www.jaspersoft.com/">Jaspersoft</a> are near this level) it’s not really possible to consider Google Docs a suitable contender while it rests a long, long way behind Excel.</p>
<p><strong>2. Load And Usage Performance For Large Sheets</strong></p>
<p>Many organisations use Excel to manage very large amounts of data and do modelling on that data using some pretty complicated formulas. I’d say being able to handle these sheets with ease on a mid-range PC typical of many office settings should be a very high priority.</p>
<p>Unfortunately Google Docs significantly disappoints. In some simple tests with opening one large sheet, amending some fields and waiting for the recalculation Excel actually finished before we were able to enter the field on Google. This was repeated on five separate mid range machines with above average Internet connections and two gigabytes of RAM.</p>
<p><strong>3. The Range Of Data Analysis And Presentation Tools In Excel Blows Google Away</strong></p>
<p>Google does have the basics right here. Sorting data and pivot tables worked well and relatively quickly (although on the machines we tested Excel was always faster as noted above) and was easy to figure out for an experienced Spreadsheet user.</p>
<p>The Data Analysis TookPak in Excel however is just so powerful it’ll be a long time before any Spreadsheet can match it &#8211; let alone an online-only solution. Many challenging University level and beyond projects can be completed using these tools as most statistical functions are supported. A good guide can be <a href="http://office.microsoft.com/en-us/excel-help/use-the-analysis-toolpak-to-perform-complex-data-analysis-HP010090842.aspx">found here</a> which also uncovers some of the pitfalls of using a spreadsheet for some of these tasks.</p>
<p><strong>4. Change In Scripting Language</strong></p>
<p>Whilst this is not necessarily a fair criticism of Google Docs they have chosen to use Javascript as their scripting language whereas Microsoft uses VBA (Visual Basic for Applications). Not only are more casual users familiar with BASIC from their education &#8211; it takes school children who’ve learned BASIC just a few hours to get scripting in Excel at a simple level but existing spreadsheets are now significantly more difficult to port to Google Docs. Any corporation with a range of large sheets containing scripts needs to think very carefully about a move.</p>
<p><strong>5. Security Concerns</strong></p>
<p>“Security consultant <a href="http://www.barkah.org/">Ade Barkah</a> checked in with us to alert us to a couple of serious security issues associated to Google Docs, the web-based office software from the world’s most famous search engine company, giving a whole new meaning to its <a href="http://www.google.com/corporate/">mission</a> to make the world’s information universally accessible.”<br />
<a href="http://techcrunch.com/2009/03/26/more-security-loopholes-found-in-google-docs/">TechCrunch 2009</a></p>
<p>Throughout the years since it’s launched there have been a number of so far minor security issues with Google Docs. However minor these have been and however quickly Google has fixed them corporations used to controlling their own security will be concerned with these issues. Microsoft hasn’t always had a perfect reputation for security but to be fair to them spreadsheets on your own private server haven’t been busy sharing a few graphs of private information with the World Wide Web.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/excelicious.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/excelicious.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/excelicious.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/excelicious.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/excelicious.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/excelicious.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/excelicious.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/excelicious.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/excelicious.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/excelicious.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/excelicious.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/excelicious.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/excelicious.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/excelicious.wordpress.com/687/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=687&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://excelicious.wordpress.com/2012/01/24/the-five-reasons-google-docs-is-not-ready-to-replace-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c0a782e88fdb3d4a6fb639eeeae948b?s=96&#38;d=identicon" medium="image">
			<media:title type="html">geoffness</media:title>
		</media:content>
	</item>
		<item>
		<title>2011 in review</title>
		<link>http://excelicious.wordpress.com/2012/01/01/2011-in-review/</link>
		<comments>http://excelicious.wordpress.com/2012/01/01/2011-in-review/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 00:59:41 +0000</pubDate>
		<dc:creator>geoffness</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://excelicious.wordpress.com/?p=683</guid>
		<description><![CDATA[The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog. Here&#8217;s an excerpt: The concert hall at the Syndey Opera House holds 2,700 people. This blog was viewed about 21,000 times in 2011. If it were a concert at Sydney Opera House, it would take about 8 sold-out performances for that many [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=683&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.</p>
<div style="background:url('/wp-content/mu-plugins/annual-reports/img/emailteaser.jpg') no-repeat center center;height:300px;"></div>
<p>Here&#8217;s an excerpt:</p>
</p>
<blockquote><p>The concert hall at the Syndey Opera House holds 2,700 people.  This blog was viewed about <strong>21,000</strong> times in 2011.  If it were a concert at Sydney Opera House, it would take about 8 sold-out performances for that many people to see it.</p></blockquote>
<p><a href="/2011/annual-report/">Click here to see the complete report.</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/excelicious.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/excelicious.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/excelicious.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/excelicious.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/excelicious.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/excelicious.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/excelicious.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/excelicious.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/excelicious.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/excelicious.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/excelicious.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/excelicious.wordpress.com/683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/excelicious.wordpress.com/683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/excelicious.wordpress.com/683/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=683&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://excelicious.wordpress.com/2012/01/01/2011-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c0a782e88fdb3d4a6fb639eeeae948b?s=96&#38;d=identicon" medium="image">
			<media:title type="html">geoffness</media:title>
		</media:content>
	</item>
		<item>
		<title>Combining chart types</title>
		<link>http://excelicious.wordpress.com/2011/10/26/combining-chart-types/</link>
		<comments>http://excelicious.wordpress.com/2011/10/26/combining-chart-types/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 11:06:49 +0000</pubDate>
		<dc:creator>geoffness</dc:creator>
				<category><![CDATA[Charts]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[combination chart types]]></category>
		<category><![CDATA[line-area]]></category>

		<guid isPermaLink="false">http://excelicious.wordpress.com/?p=662</guid>
		<description><![CDATA[Wow, it&#8217;s been a long time. This is a post I had planned for some time ago but didn&#8217;t get around to until now &#8211; as many All Black supporters might say, about bloody time&#8230; In a made-up scenario I have two rates to report on, Metric 1 and Metric 2. An indicator of good [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=662&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wow, it&#8217;s been a long time. This is a post I had planned for some time ago but didn&#8217;t get around to until now &#8211; as many All Black supporters might say, <a href="http://www.stuff.co.nz/sport/rugby/5840301/Black-cloud-lifts-World-media-hails-ABs">about bloody time</a>&#8230;</p>
<p>In a made-up scenario I have two rates to report on, Metric 1 and Metric 2. An indicator of good performance is that Metric 2 sits 5-10% above Metric 1. So when I plot the monthly data, as well as the two Metrics time series I&#8217;ll add in another series called Difference, that will be calculated as Metric 2 &#8211; Metric 1. I&#8217;ll also add in the constant series Target 1 (5%) and Target 2 (10%), and what I want to see is the Difference series sitting between these two targets. Here&#8217;s what that looks like:</p>
<p><a href="http://excelicious.files.wordpress.com/2011/10/perf11.png"><img src="http://excelicious.files.wordpress.com/2011/10/perf11.png?w=600&#038;h=411" alt="" title="perf1" width="600" height="411" class="aligncenter size-full wp-image-670" /></a></p>
<p>Now, I don&#8217;t know what you think of that, but to me it&#8217;s confusing. The difference between Metric 1 and 2 and where it sits in relation to the 5% and 10% marks is the key indicator I need to follow, but both Metric 1 and 2 are also important to provide context. Putting them all together on the same line chart makes it harder than it needs to be to see what the indicator is doing.</p>
<p>Thankfully, there is a much simpler way to present this, which avoids the need for the eye to track all five time series together on the chart, and also manages to signal much more clearly where the key indicator is in relation to its target. To do this I can use the relatively simple expedient of combining different chart types.</p>
<p>First, I right-click the Metric 1 time series, select &#8216;Change Series Chart Type&#8230;&#8217; and pick out the &#8216;Stacked Area&#8217; chart type:</p>
<p><a href="http://excelicious.files.wordpress.com/2011/10/stackedarea.png"><img src="http://excelicious.files.wordpress.com/2011/10/stackedarea.png?w=600" alt="" title="stackedarea"   class="aligncenter size-full wp-image-673" /></a></p>
<p>I also format the fill of the area series to a red colour:</p>
<p><a href="http://excelicious.files.wordpress.com/2011/10/change1.png"><img src="http://excelicious.files.wordpress.com/2011/10/change1.png?w=600&#038;h=411" alt="" title="change1" width="600" height="411" class="aligncenter size-full wp-image-675" /></a></p>
<p>Next, I make the same change of chart type to the Target 1 time series. I change the colour to orange (or amber if you prefer), and the name of the series to &#8217;0-5% above&#8217;:</p>
<p><a href="http://excelicious.files.wordpress.com/2011/10/change2.png"><img src="http://excelicious.files.wordpress.com/2011/10/change2.png?w=600&#038;h=411" alt="" title="change2" width="600" height="411" class="aligncenter size-full wp-image-676" /></a></p>
<p>I remove both the Difference and the Target 2 time series from the chart, and add the Target 1 series in again, by copying the data range from the worksheet, selecting the chart and pasting. Once that&#8217;s done, I again change the chart type of the new series to stacked area, set the fill colour to green and rename it to &#8217;5-10% above&#8217;. I also change the line colour of the Metric 2 series to a dark blue to provide a little more contrast against the area charts:</p>
<p><a href="http://excelicious.files.wordpress.com/2011/10/change3.png"><img src="http://excelicious.files.wordpress.com/2011/10/change3.png?w=600&#038;h=411" alt="" title="change3" width="600" height="411" class="aligncenter size-full wp-image-678" /></a></p>
<p>And that&#8217;s done. We now don&#8217;t need to show the &#8216;Difference&#8217; series at all, as the magnitude of the difference between Metric 1 and 2 is clear without it. I also find the chart a lot simpler and more visually appealing. I should note in passing that I very rarely use the stacked area chart type, but it makes sense to me in this context.</p>
<p>Combining chart types like this is a simple and effective but under-used method &#8211; I guess that&#8217;s one side effect of the chart wizard, people assume that once the chart type is selected, that&#8217;s it. I first came across the idea at Jon Peltier&#8217;s site (<a href="http://peltiertech.com/Excel/Charts/ComboCharts.html">this page</a> has a lot of cool examples), it&#8217;s been a handy tool ever since.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/excelicious.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/excelicious.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/excelicious.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/excelicious.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/excelicious.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/excelicious.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/excelicious.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/excelicious.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/excelicious.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/excelicious.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/excelicious.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/excelicious.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/excelicious.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/excelicious.wordpress.com/662/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=662&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://excelicious.wordpress.com/2011/10/26/combining-chart-types/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c0a782e88fdb3d4a6fb639eeeae948b?s=96&#38;d=identicon" medium="image">
			<media:title type="html">geoffness</media:title>
		</media:content>

		<media:content url="http://excelicious.files.wordpress.com/2011/10/perf11.png" medium="image">
			<media:title type="html">perf1</media:title>
		</media:content>

		<media:content url="http://excelicious.files.wordpress.com/2011/10/stackedarea.png" medium="image">
			<media:title type="html">stackedarea</media:title>
		</media:content>

		<media:content url="http://excelicious.files.wordpress.com/2011/10/change1.png" medium="image">
			<media:title type="html">change1</media:title>
		</media:content>

		<media:content url="http://excelicious.files.wordpress.com/2011/10/change2.png" medium="image">
			<media:title type="html">change2</media:title>
		</media:content>

		<media:content url="http://excelicious.files.wordpress.com/2011/10/change3.png" medium="image">
			<media:title type="html">change3</media:title>
		</media:content>
	</item>
		<item>
		<title>An Undo Stack in VBA</title>
		<link>http://excelicious.wordpress.com/2011/07/14/an-undo-stack-in-vba/</link>
		<comments>http://excelicious.wordpress.com/2011/07/14/an-undo-stack-in-vba/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 11:43:45 +0000</pubDate>
		<dc:creator>geoffness</dc:creator>
				<category><![CDATA[Classes]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[stack]]></category>

		<guid isPermaLink="false">http://excelicious.wordpress.com/?p=640</guid>
		<description><![CDATA[I&#8217;m working on an Excel add-in which will allow a user to perform operations on cells. I&#8217;d also like to allow the user to &#8216;undo&#8217; these operations. Excel itself, of course, does have an Undo button (shortcut Ctrl + Z), but this works only to undo changes made in the user interface, and is not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=640&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on an Excel add-in which will allow a user to perform operations on cells. I&#8217;d also like to allow the user to &#8216;undo&#8217; these operations. Excel itself, of course, does have an Undo button (shortcut Ctrl + Z), but this works only to undo changes made in the user interface, and is not going to help for changes made by VBA. This means the add-in will need to remember each operation performed and have them ready to supply for un-doing should the user want to do so.</p>
<p>Many people have created their own general solutions for undoing changes made in VBA &#8211; for instance, here&#8217;s one from Jan Karel Pieterse (who also created the hugely useful <a href="http://www.jkp-ads.com/OfficeMarketPlaceNM-EN.asp" target="_blank">Name Manager</a> add-in): <a href="http://www.jkp-ads.com/Articles/UndoWithVBA00.asp" target="_blank">Undo With Excel VBA</a>. However I decided not to use a solution like this &#8211; it&#8217;s quite a lot of code to add to a project, and it is very general.</p>
<p>In this case I&#8217;m happy to write a more specific solution, which copes with undoing a specific action, by simply delegating the work of undoing the action to the object which did the action in the first place. Here&#8217;s an example:<br />
<pre class="brush: vb;">' CellTest Class - allows calling code to change the value of a
' cell and then change it back

'*****************************************************************
' Private Variables
'*****************************************************************
Private mCell As Range
Private vOrigFormula As Variant

'*****************************************************************
' Public Properties
'*****************************************************************
Public Property Get Address() As String
  Address = mCell.Address
End Property

Public Property Set Cell(ByRef rCell As Range)
  Set mCell = rCell
  vOrigFormula = rCell.Formula
End Property

'*****************************************************************
' Public Methods
'*****************************************************************
Public Sub Change(ByVal sText As String)
  mCell.Value = sText
End Sub

Public Sub ChangeBack()
  mCell.Formula = vOrigFormula
End Sub
</pre></p>
<p>So what about storing up a list of operations for undoing? This is ideally suited to a stack. <a href="http://en.wikipedia.org/wiki/Stack_(data_structure)">Stacks</a> are neat data structures &#8211; they don&#8217;t do much, but they do it well and they&#8217;re really easy to code. Here&#8217;s one I picked up from the <a href="http://www.amazon.com/VBA-Developers-Handbook-2nd-Getz/dp/0782129781">VBA Developer&#8217;s Handbook</a> and tweaked a little to suit. There are two classes, StackItem and Stack. StackItem simply stores a value and a reference to another StackItem object &#8211; the next item on the stack.</p>
<p><pre class="brush: vb;">' StackItem class holds a reference to the object it refers to and
' a reference to the next item in the stack

Public Value As Variant
Public NextItem As StackItem
</pre></p>
<p>Stack stores a reference to the item on the top of the stack, and exposes the functions Push (to push a new item on to the top) and Pop (to remove the top item and return a reference to it). Properties IsEmpty and Peek tell you if there are any items in the stack, and what the value of the top item is (without removing it), respectively. There&#8217;s a very nice visual explanation of how this looks <a href="http://www.cosc.canterbury.ac.nz/mukundan/dsal/StackAppl.html">here</a>.</p>
<p><pre class="brush: vb;">' Stack holds a reference to the top item in the stack data structure
' and manages the adding and removing of stack items

Private siTop As StackItem

'*****************************************************************
' Public Properties
'*****************************************************************
Public Property Get IsEmpty() As Boolean
    IsEmpty = siTop Is Nothing
End Property

Public Property Get Peek() As Variant
    If IsObject(siTop.Value) Then
        Set Peek = siTop.Value
    Else
        Peek = siTop.Value
    End If
End Property

'*****************************************************************
' Public Methods
'*****************************************************************
Public Function Push(ByRef varIn As Variant) As Boolean

    Dim siNew As StackItem

On Error GoTo PushError

    Set siNew = New StackItem
    If IsObject(varIn) Then
        Set siNew.Value = varIn
    Else
        siNew.Value = varIn
    End If
    Set siNew.NextItem = siTop
    Set siTop = siNew
    
    Push = True
    
Exit Function

PushError:
    Push = False
End Function

Public Function Pop() As Variant

    If IsObject(siTop.Value) Then
        Set Pop = siTop.Value
    Else
        Pop = siTop.Value
    End If
    Set siTop = siTop.NextItem

End Function</pre></p>
<p>So now to store an actions for undoing, I just need to push the object which performed it onto the undo stack. Every time I wish to actually undo an action, I just pop the object reference off, and instruct it to undo.</p>
<p>Next time, I&#8217;ll demonstrate how this looks in practice.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/excelicious.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/excelicious.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/excelicious.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/excelicious.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/excelicious.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/excelicious.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/excelicious.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/excelicious.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/excelicious.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/excelicious.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/excelicious.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/excelicious.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/excelicious.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/excelicious.wordpress.com/640/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=640&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://excelicious.wordpress.com/2011/07/14/an-undo-stack-in-vba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c0a782e88fdb3d4a6fb639eeeae948b?s=96&#38;d=identicon" medium="image">
			<media:title type="html">geoffness</media:title>
		</media:content>
	</item>
		<item>
		<title>Maintaining SAS formats in Excel</title>
		<link>http://excelicious.wordpress.com/2011/06/30/maintaining-sas-formats-in-excel/</link>
		<comments>http://excelicious.wordpress.com/2011/06/30/maintaining-sas-formats-in-excel/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 11:53:49 +0000</pubDate>
		<dc:creator>geoffness</dc:creator>
				<category><![CDATA[SAS]]></category>
		<category><![CDATA[call execute]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[libname]]></category>
		<category><![CDATA[macro]]></category>

		<guid isPermaLink="false">http://excelicious.wordpress.com/?p=628</guid>
		<description><![CDATA[For one of the subject areas I deal with day to day, categorical data values are often stored in the database in narrow character fields, so we need to apply SAS formats to get readable values out in reports. To maintain these formats I store them in an Excel workbook, looking roughly like this: This [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=628&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For one of the subject areas I deal with day to day, categorical data values are often stored in the database in narrow character fields, so we need to apply SAS formats to get readable values out in reports. To maintain these formats I store them in an Excel workbook, looking roughly like this:</p>
<p><a href="http://excelicious.files.wordpress.com/2011/06/format_table.jpg"><img src="http://excelicious.files.wordpress.com/2011/06/format_table.jpg?w=600" alt="" title="format_table"   class="aligncenter size-full wp-image-630" /></a></p>
<p>This is a relatively painless way to manage keeping SAS formats up to date, as well as making them easily accessible to people who need to inspect them. Each format is stored in a named range, with the name of the range matching the name of the format. The column headers are chosen to agree with the SAS Format procedure <a href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473477.htm#a002473479" target="_blank">requirement for an input control data set</a>. The above range, for instance, would be named &#8216;excel_user&#8217;, and would be used to input the required data for a character format (Type=&#8217;C') also named &#8216;excel_user&#8217; (Fmtname).</p>
<p>So how do I get them into SAS from Excel? Once again, the <a href="http://support.sas.com/documentation/cdl/en/acpcref/63184/HTML/default/a002107204.htm" target="_blank">SAS/ACCESS Excel libname statement</a> is helpful here. First, we assign a libref &#8216;wb&#8217; to the workbook holding the format ranges, and another libref &#8216;sasprogs&#8217; which will be used to store the format catalog:<br />
<pre class="brush: cpp;">libname wb Excel &quot;&amp;path.\formats.xls&quot; ver=2002 ;
libname sasprogs &quot;&amp;path&quot; ;</pre></p>
<p>Next we need to get a list of all the ranges that we&#8217;re interested in here. In this workbook the only named ranges are the ones containing the formats. Any other names that the libname engine detects will be the names of worksheets, which will contain a &#8216;$&#8217; character. So, we simply exclude these from the query against the dictionary.tables table:<br />
<pre class="brush: cpp;">proc sql;
  create table tmp as
  select memname
  from dictionary.tables
  where libname='WB' 
    and index(memname, '$') = 0 ;
quit;</pre></p>
<p>So now the table &#8216;tmp&#8217; holds a list of all the format range names in the workbook. Now we need to use this table to guide SAS in building those formats. What we need to do is to submit a proc format statement for every one of those names. Like so:</p>
<p><pre class="brush: cpp;">%macro load_fmt(name) ;
  proc format library=sasprogs.sasfmts cntlin=wb.&amp;name ;
%mend load_fmt;</pre></p>
<p>Now we simply need to loop through the set of names to load each of the formats into the sasprogs.sasfmts catalog:<br />
<pre class="brush: cpp;">data _null_;
  set tmp;
  call execute('%load_fmt('||memname||')') ;
run;</pre></p>
<p>All that&#8217;s left to do now is a little tidying up:</p>
<p><pre class="brush: cpp;">/*Close the file*/
libname wb clear ;
/*Inspect format contents*/
proc format library=sasprogs.sasfmts fmtlib cntlout=sasprogs.sasfmt_data; run;
/*Add them into the search path*/
options fmtsearch=(library sasfmts);</pre></p>
<p>And we&#8217;re done &#8211; all the formats are now loaded and available in the SAS session. Now if there are any changes, or a new format needs to be created, just add it into the file, save it and re-run this script. Sorted!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/excelicious.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/excelicious.wordpress.com/628/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/excelicious.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/excelicious.wordpress.com/628/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/excelicious.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/excelicious.wordpress.com/628/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/excelicious.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/excelicious.wordpress.com/628/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/excelicious.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/excelicious.wordpress.com/628/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/excelicious.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/excelicious.wordpress.com/628/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/excelicious.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/excelicious.wordpress.com/628/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=excelicious.wordpress.com&amp;blog=6322710&amp;post=628&amp;subd=excelicious&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://excelicious.wordpress.com/2011/06/30/maintaining-sas-formats-in-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c0a782e88fdb3d4a6fb639eeeae948b?s=96&#38;d=identicon" medium="image">
			<media:title type="html">geoffness</media:title>
		</media:content>

		<media:content url="http://excelicious.files.wordpress.com/2011/06/format_table.jpg" medium="image">
			<media:title type="html">format_table</media:title>
		</media:content>
	</item>
	</channel>
</rss>
