<?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/"
	>

<channel>
	<title>What a Palaver &#187; Excel</title>
	<atom:link href="http://whatapalaver.co.uk/category/geeky-corner/excel-geeky-corner-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://whatapalaver.co.uk</link>
	<description></description>
	<lastBuildDate>Sun, 15 Apr 2012 22:07:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>NHS Excel website expands</title>
		<link>http://whatapalaver.co.uk/2012/04/nhs-excel-website-expands/</link>
		<comments>http://whatapalaver.co.uk/2012/04/nhs-excel-website-expands/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 22:07:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[NHS Excel]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=2274</guid>
		<description><![CDATA[I&#8217;ve added a number of excel tutorials to the NHS Excel website and this will become the home for most of my excel related content. It&#8217;s been a busy month at work due to year end and the agreement of balances exercise but its been interesting from an excel point of view. We&#8217;ve had to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2012%2F04%2Fnhs-excel-website-expands%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2012%2F04%2Fnhs-excel-website-expands%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://nhsexcel.com" rel="nofollow" ><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-2275" title="NHS Excel" src="http://whatapalaver.co.uk/wp-content/uploads/2012/04/Screen-shot-2011-12-04-at-16.51.05.png" alt="" width="101" height="101" /></a>I&#8217;ve added a number of excel tutorials to the <a href="http://nhsexcel.com" rel="nofollow" >NHS Excel website</a> and this will become the home for most of my excel related content.</p>
<p>It&#8217;s been a busy month at work due to year end and the agreement of balances exercise but its been interesting from an excel point of view. We&#8217;ve had to work across a departments and this has thrown up a number of issues, not least of which has been the problem of people using different versions of excel to work on a single workbook. This month I&#8217;ve written a <a href="http://nhsexcel.com/backwards-compatability-create-pivot-tables-that-work-in-excel-2003/" rel="nofollow" >tutorial explaining how to force Excel 2007 to work in compatibility mode</a> so that you can create pivot tables that work in earlier versions of excel.</p>
<p>I&#8217;ve also written some <a href="http://nhsexcel.com/how-to-use-excel-vba-to-log-in-to-a-website/" rel="nofollow" >VBA code to automate log-ins to password protected websites</a>. The idea of this is to use in conjunction with a website query to download data from a central NHS website to a spreadsheet on a regular basis.</p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2012/04/nhs-excel-website-expands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Waterfall Charts and the X-Axis</title>
		<link>http://whatapalaver.co.uk/2011/02/waterfall-charts-and-the-x-axis/</link>
		<comments>http://whatapalaver.co.uk/2011/02/waterfall-charts-and-the-x-axis/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 17:07:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[bar chart]]></category>
		<category><![CDATA[stacked]]></category>
		<category><![CDATA[waterfall chart]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=2156</guid>
		<description><![CDATA[Waterfall charts have become all the rage in the office of late. They are popping up all over. I suppose it is no surprise, it’s springtime and we are well into the planning process and a waterfall chart is the perfect way to demonstrate how a starting position either increases or decreases through a series [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2011%2F02%2Fwaterfall-charts-and-the-x-axis%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2011%2F02%2Fwaterfall-charts-and-the-x-axis%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Waterfall charts have become all the rage in the office of late. They are popping up all over. I suppose it is no surprise, it’s springtime and we are well into the planning process and a waterfall chart is the perfect way to demonstrate how a starting position either increases or decreases through a series of changes.</p>
<p>So in our case, when planning for next year’s acute healthcare budget, we may start with the forecast outturn for the current year, throw our hands up in despair and then work through a series of savings initiatives that would hopefully bring us back to a position of affordability.</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2011/02/SIMPLE-WATERFALL.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-2157" title="SIMPLE WATERFALL CHART" src="http://whatapalaver.co.uk/wp-content/uploads/2011/02/SIMPLE-WATERFALL.jpg" alt="" width="531" height="298" /></a></p>
<p>This can be easily demonstrated by the use of a simple waterfall chart which is a version of a stacked bar chart with some elements formatted so that they are not visible.</p>
<p>Here you can see the driving table and the series clearly visible before formatting.</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2011/02/SIMPLE-WATERFALL-TABLE-CHART.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-2158" title="SIMPLE WATERFALL TABLE &amp; CHART" src="http://whatapalaver.co.uk/wp-content/uploads/2011/02/SIMPLE-WATERFALL-TABLE-CHART.jpg" alt="" width="521" height="499" /></a></p>
<p>Life in the waterfall chart world becomes a little more difficult if your movements are going to take you either above or below the x-axis.</p>
<p>You can imagine this happening if instead of starting with forecast outturn we model the affect on the planned deficit/surplas. The chart below shows the starting position before QIPP or savings programs and the incremental affect of appyling each projected saving.</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2011/02/COMPLEX-WATERFALL1.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-2160" title="COMPLEX WATERFALL" src="http://whatapalaver.co.uk/wp-content/uploads/2011/02/COMPLEX-WATERFALL1.jpg" alt="" width="603" height="325" /></a></p>
<p>The table required to generate this chart is quite complex but it does at least illustrate the position accurately if the data crosses the x-axis. The simple model shown above would display the data incorrectly.</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2011/02/COMPLEX-WATERFALL-TABLE.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-2161" title="COMPLEX WATERFALL TABLE" src="http://whatapalaver.co.uk/wp-content/uploads/2011/02/COMPLEX-WATERFALL-TABLE.jpg" alt="" width="606" height="258" /></a></p>
<p>You can download the spreadsheet I used to draw up these examples which will show all the relevant formulas <a href="http://whatapalaver.co.uk/wp-content/uploads/2011/02/Waterfall-Chart.xlsx">Waterfall Chart.xlsx</a> but I would also recommend that you take a look at the excellent <a href="http://peltiertech.com/Excel/Charts/waterfallcrossing.html" rel="nofollow" >Peltier website</a> which explains the creation of both simple and complex waterfall charts in more detail and describes the formatting process step by step &#8211; I used this site to learn the techniques.<a href="http://whatapalaver.co.uk/wp-content/uploads/2011/02/COMPLEX-WATERFALL.jpg"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2011/02/waterfall-charts-and-the-x-axis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Managing Version Control in Excel using Macros</title>
		<link>http://whatapalaver.co.uk/2010/12/managing-version-control-in-excel-using-macros/</link>
		<comments>http://whatapalaver.co.uk/2010/12/managing-version-control-in-excel-using-macros/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:06:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=2057</guid>
		<description><![CDATA[If you work with spreadsheets that are regularly being updated and amended by multiple users then you will know something about version control. If you then add to this mix, the need to periodically distribute the updated spreadsheet for public viewing you will be more than well aware that Microsoft Excel isn&#8217;t really designed to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F12%2Fmanaging-version-control-in-excel-using-macros%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F12%2Fmanaging-version-control-in-excel-using-macros%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you work with spreadsheets that are regularly being updated and amended by multiple users then you will know something about version control. If you then add to this mix, the need to periodically distribute the updated spreadsheet for public viewing you will be more than well aware that Microsoft Excel isn&#8217;t really designed to handle version control very well.</p>
<p>I&#8217;m currently working with NHS contract proposals for the new financial year. The models are complex and the figures involved are high. We are up to version 20 already and the first cut hasn&#8217;t even been published. Between each issued version I know I will be inundated with emails asking what has changed and why.</p>
<p>I&#8217;m getting twitchy just thinking about it and I&#8217;m already dreaming about version control.</p>
<p>I&#8217;ve put together a few macros to enforce some rules for version control and to maintain an audit trail of changes and versions.</p>
<p><span style="text-decoration: underline;">Methodology for Controlling Versions in Microsoft Excel</span><br />
My spreadsheet includes tabs of data related to patient care, but it will work for any model that you wish to maintain a version trail for.</p>
<p>You need a tab for documenting the changes between each version. Mine is called Version Control but then I&#8217;m an accountant and don&#8217;t really do imagination.<br />
On this sheet are two named ranges, VERSION and FILENAME (in B7 and B9 respectively) and two macro buttons for running the save options.</p>
<p style="text-align: center;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/12/VERSION.bmp"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-2063" title="VERSION" src="http://whatapalaver.co.uk/wp-content/uploads/2010/12/VERSION.bmp" alt="" /></a></p>
<p>When the document is saved I want the user to overwrite the master document so that it always shows the latest version and I want them to save the file to a version folder and increment the filename to the next version number. So each save process creates one new file and overwrites another.</p>
<p>To ensure this happens just as I want, I need to prevent users from saving the spreadsheet in their own way. I do this by writing a procedure in the workbook object that will run whenever they attempt to save the document.</p>
<pre class="brush: vb; title: ; notranslate">Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True
    MsgBox &quot;When you are happy with the changes, please go to the VERSION CONTROL tab and freeze the document to save&quot;
End Sub</pre>
<p>This directs the user back to the Version Control tab where they can either perform a FREEZE save or a temporary save. The temporary save is for convenience in case large changes are being made, it will save a single version with a temporary filename. The FREEZE save creates a new version and overwrites the master document, it also requires the user to enter some notes relating to the changes made.</p>
<p>Here&#8217;s the code for the FREEZE save:</p>
<pre class="brush: vb; title: ; notranslate">Sub FreezeWorkbook()
'Working in Excel 97-2010
    Dim FileExtStr As String
    Dim FileFormatNum As Long
    Dim Sourcewb As Workbook
    Dim wsVC As Worksheet
    Dim Destwb As Workbook
    Dim VersionFilePath As String
    Dim VersionFileName As String
    Dim MasterFilePath As String
    Dim MasterFileName As String
    Dim VersionDate As String
    Dim Version As String
    Dim CurrentVersion As String
    Dim iLastRowVC As Long 'LAST ROW IN VERSION CONTROL SHEET
    Dim Author As String
    Dim Changes As String
    Dim AmendRef As String

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    'UPDATE THE VERSION CONTROL DETAILS
    ActiveSheet.Unprotect
    Set wsVC = Worksheets(&quot;VERSION CONTROL&quot;)
    iLastRowVC = wsVC.Cells(Rows.Count, &quot;B&quot;).End(xlUp).Row

    'Current Version
    CurrentVersion = wsVC.Range(&quot;a&quot; &amp; iLastRowVC).Value

     'Insert version
     Version = InputBox(&quot;Please enter the next incremental Version Number (Current   Version = &quot; &amp; CurrentVersion &amp; &quot;)&quot;)
    wsVC.Range(&quot;a&quot; &amp; iLastRowVC + 1).Value = Version

    'Insert version date
    VersionDate = Format(Now, &quot;dd-mm-yy hh-mm-ss&quot;)
    wsVC.Range(&quot;B&quot; &amp; iLastRowVC + 1).Value = VersionDate

    Author = InputBox(&quot;Please enter your name&quot;)
    wsVC.Range(&quot;c&quot; &amp; iLastRowVC + 1) = Author

    Changes = InputBox(&quot;Please enter a brief description of changes made&quot;)
    wsVC.Range(&quot;d&quot; &amp; iLastRowVC + 1) = Changes

    AmendRef = InputBox(&quot;Enter the ref to the Amendments Document or N/A if none available&quot;)
    wsVC.Range(&quot;e&quot; &amp; iLastRowVC + 1) = AmendRef

    wsVC.Range(&quot;F&quot; &amp; iLastRowVC + 1).Value = Range(&quot;HLACTIVITY&quot;) 'Returns a the total activity value from a named range within the spreadsheet
    wsVC.Range(&quot;G&quot; &amp; iLastRowVC + 1).Value = Range(&quot;HLVALUE&quot;) 'Returns a the total financial value from a named range within the spreadsheet

    'Save the master workbook
        Application.DisplayAlerts = False
        Set Sourcewb = ActiveWorkbook

    'Force the file extension to remain as Excel 97-2003
        FileExtStr = &quot;.xls&quot;: FileFormatNum = -4143

    'Overwrite the master report or create it if it doesn't yet exist
    MasterFilePath = &quot;c:\My Documents\2010-11 A&amp;F Contract Templates\Masters\&quot; 'Amend to suit your filing system
    MasterFileName = Range(&quot;FILENAME&quot;) &amp; &quot; Master&quot;

    Range(&quot;VERSION&quot;).FormulaR1C1 = Version 'Overwrite the version number on the version control sheet

    With Sourcewb
        .SaveAs MasterFilePath &amp; MasterFileName, FileFormat:=FileFormatNum, WriteResPassword:=&quot;&quot; 'This ensures that the master is not password protected otherwise I get problems overwriting the file
    End With
    Application.DisplayAlerts = True

    'save the version workbook
    Set Sourcewb = ActiveWorkbook
    'Force the file extension to remain as Excel 97-2003
        FileExtStr = &quot;.xls&quot;: FileFormatNum = -4143

    'Save the new workbook and close it
    VersionFilePath = &quot;c:\My Documents\A2010-11 A&amp;F Contract Templates\Versions\RAP\&quot;

    VersionFileName = Range(&quot;FILENAME&quot;) &amp; &quot; &quot; &amp; Version
    ActiveSheet.Protect

    With Sourcewb
        .SaveAs VersionFilePath &amp; VersionFileName &amp; FileExtStr, FileFormat:=FileFormatNum, WriteResPassword:=&quot;password&quot; 'this sets password protection in place for the version spreadsheets
    End With

    MsgBox &quot;New version saved as &quot; &amp; VersionFilePath &amp; VersionFileName &amp; &quot; and Master Updated&quot;

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub</pre>
<p>and the Temporary Save code which saves the file in the versions folder with a &#8220;Temp&#8221; suffix:</p>
<pre class="brush: vb; title: ; notranslate">Sub TempSave()
'Working in Excel 97-2010
    Dim FileExtStr As String
    Dim FileFormatNum As Long
    Dim Sourcewb As Workbook
    Dim Destwb As Workbook
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim TempVersion As String
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    Set Sourcewb = ActiveWorkbook

    'Force the file extension to remain as Excel 97-2003
        FileExtStr = &quot;.xls&quot;: FileFormatNum = -4143

    ActiveSheet.Unprotect
    TempFilePath = &quot;c:\My Documents\2010-11 A&amp;F Contract Templates\Versions\&quot;
    TempVersion = Format(Now, &quot;yy-mm-dd hh-mm-ss&quot;)
    TempFileName = &quot;Temp &quot; &amp; Range(&quot;FILENAME&quot;) &amp; &quot; &quot; &amp; TempVersion
    Range(&quot;VERSION&quot;).FormulaR1C1 = TempVersion
     ActiveSheet.Protect

    With Sourcewb
        .SaveAs TempFilePath &amp; TempFileName &amp; FileExtStr, FileFormat:=FileFormatNum
    End With

    MsgBox &quot;New version saved as &quot; &amp; TempFilePath &amp; TempFileName

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub</pre>
<p>I&#8217;ve used the plugin Syntax Higlighter to display the VBA code. It looks great but unfortunately it doesn&#8217;t copy and paste well. You can download a blank spreadsheet that includes the modules above if you want to copy them &#8211; <a href='http://whatapalaver.co.uk/wp-content/uploads/2010/12/Version-Control-Macro.xls'>Version Control Macro.xls</a>.</p>
<p>As usual I have botched this macro together from many hints and tips found elsewhere on the interweb, this <a href="http://www.rondebruin.nl/saveas.htm" rel="nofollow" >page from Ron de Bruin</a> was particularly useful.</p>
<p>I think I need to add some loops into the input box code because users can choose not to enter any comments or an appropriate version number at the moment and I have no means of controlling the errors.</p>
<p>I&#8217;ve also had to run this without any password protection on the master file. If I password protect it the macro fails with a write protection error. I&#8217;m not sure if I ought to be able to get around this or whether it is not actually possible to save over a write protected file. Dunno.</p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2010/12/managing-version-control-in-excel-using-macros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Personlised FIRST Training Schedules &#8211; A Marathon in 3 days a Week</title>
		<link>http://whatapalaver.co.uk/2010/10/personlised-first-training-schedules-a-marathon-in-3-days-a-week/</link>
		<comments>http://whatapalaver.co.uk/2010/10/personlised-first-training-schedules-a-marathon-in-3-days-a-week/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 22:11:02 +0000</pubDate>
		<dc:creator>warriorwoman</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[Running]]></category>
		<category><![CDATA[Sport]]></category>
		<category><![CDATA[excel spreadsheet]]></category>
		<category><![CDATA[FIRST]]></category>
		<category><![CDATA[Furman Institute]]></category>
		<category><![CDATA[marathon]]></category>
		<category><![CDATA[Marathon Schedule]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=1993</guid>
		<description><![CDATA[Crossing the line at the end of the Great North run I felt elated, 10 mins later I was sick and feverish. Any fitness I had in September disappeared over the next 5 weeks as I feebly battled a chest infection. Now that I’ve more or less cleared my chest and started venturing back onto [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F10%2Fpersonlised-first-training-schedules-a-marathon-in-3-days-a-week%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F10%2Fpersonlised-first-training-schedules-a-marathon-in-3-days-a-week%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Crossing the line at the end of the Great North run I felt elated, 10 mins later I was sick and feverish.</p>
<p>Any fitness I had in September disappeared over the next 5 weeks as I feebly battled a chest infection. Now that I’ve more or less cleared my chest and started venturing back onto the treadmill or out for a Grid Run I find myself struck down once again, this time by a bolt to the back of the knee. I can’t run without yelping and trying to do so has left me with a permanent limp.</p>
<p>This really does not bode well for my marathon training plans.</p>
<p>I haven’t been resting on my laurels though. While my body may well have been degenerating rapidly my mind has been busy researching training schedules and drawing up plans.</p>
<p>Hal Higdon has a series of well respected schedules available but they are relentless and require you to commit to 5 runs per week and a max weekly mileage of 44 for the intermediate program. At my pace that’s a lot of my life to spend running.</p>
<p>I accept that marathon training is supposed to be gruelling, the reward doesn’t come after a days pain but after 4 months of commitment and then a days pain but if there are alternatives I’m going to be tempted.</p>
<p>Fortunately there are alternatives and plenty of them.</p>
<p>One of my overriding requirements for this marathon is that I’ve got to get faster – not fast, but I don’t want to be running around that course after 7 hours. There is one schedule on the market that claims to increase the pace of anyone who sticks to the plan and that is FIRST from the Furman Institute of Running and Scientific Training. It seems that even Boston qualifiers have achieved PRs using the FIRST method of 3 runs per week, and if it can work for someone at the top of their game its bound to do something for me.</p>
<p>Their method is based on a 3+2 schedule called <a href="http://www.amazon.co.uk/gp/product/159486649X?ie=UTF8&amp;tag=warriorwomen-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=159486649X" rel="nofollow" >&#8220;Run Less, Run faster&#8221;</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.co.uk/e/ir?t=warriorwomen-21&amp;l=as2&amp;o=2&amp;a=159486649X" border="0" alt="" width="1" height="1" />, not to be mistaken with “Train Less, Run Faster” because although you only run 3 times a week you are supposed to take part in some fairly energetic cross training on 2 other days in the week.</p>
<p>The key to the success of the FIRST plan seems to be related to the nature of the 3 runs. Each one is very specific and targeted at improving a key element of your running fitness. Key Run 1 is a track repeat session, ideally suited to treadmill workouts, Key run 2 is a tempo workout and Key run 3 is the Long Run a familiar staple of any marathon plan. <a href="http://www.runnersworld.com/article/0,7120,s6-238-244--8257-1-1X2X3X4X5X6-7,00.html" rel="nofollow" >RunnersWorld</a> has a useful article giving an overview of the approach and <a href="http://www.fetcheveryone.com/viewtopic.php?id=39828&amp;page=1" rel="nofollow" >Fetcheveryone</a> has a very active forum on the topic.</p>
<p>The <a href="http://www.furman.edu/first/" rel="nofollow" >Furman website</a> has the marathon schedules available to download along with the target pace charts.</p>
<p>I’ve spent a few hours knocking up a spreadsheet that includes the FIRST Novice Marathon Plan and the FIRST Half Marathon plan along with all the recommended paces for runners achieving 5k times anywhere between 15 and 40 mins. The spreadsheet personalises the schedule so that you can select from the drop down box your latest 5k performance and see each workout broken down with your specific target paces. I’ve gone to quite a bit of effort with it because I wanted to be able to print off a clear schedule for use on the treadmill.</p>
<p style="text-align: center;"><a href="http://www.warriorwomen.co.uk/wp-content/uploads/2010/10/FIRST-personalised-marathon-schedule.jpg" rel="nofollow" ><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/11/FIRST-personalised-marathon-schedule.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="size-full wp-image-1994 aligncenter" title="FIRST-personalised-marathon-schedule" src="http://whatapalaver.co.uk/wp-content/uploads/2010/11/FIRST-personalised-marathon-schedule.jpg" alt="" width="521" height="159" /></a><br />
</a></p>
<p>If you want to try it out yourself feel free to download it and test it out:</p>
<p><a href="http://www.warriorwomen.co.uk/wp-content/uploads/2010/10/FIRST-Paces-97.xls" rel="nofollow" >FIRST Personalised Marathon and Half Marathon Schedule for Excel</a>.</p>
<p>Now all I have to do is get over my knee problems and start running.</p>
<p><em>Originally published on my <a href="http://www.warriorwomen.co.uk/2010/10/28/personlised-first-training-schedules-a-marathon-in-3-days-a-week/" rel="nofollow" >warriorwomen blog</a></em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2010/10/personlised-first-training-schedules-a-marathon-in-3-days-a-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excel Pivot Table or CrossTab to Flat List</title>
		<link>http://whatapalaver.co.uk/2010/07/excel-pivot-table-or-crosstab-to-flat-list/</link>
		<comments>http://whatapalaver.co.uk/2010/07/excel-pivot-table-or-crosstab-to-flat-list/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 06:49:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[crosstab]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[flat list]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[Pivot Table]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=1848</guid>
		<description><![CDATA[Excel to CrossTabI often find myself struggling to deal with data that has been rendered almost unusable by the data provider who has converted it to a cross tab format. Usually they think they are helping and have probably started with a nice flat list then spent ages formatting it so the data spreads out [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F07%2Fexcel-pivot-table-or-crosstab-to-flat-list%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F07%2Fexcel-pivot-table-or-crosstab-to-flat-list%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/Excel-to-CrossTab.xls">Excel to CrossTab</a>I often find myself struggling to deal with data that has been rendered almost unusable by the data provider who has converted it to a cross tab format. Usually they think they are helping and have probably started with a nice flat list then spent ages formatting it so the data spreads out across the columns. Sometimes they have achieved this by putting the data into a pivot table but then have pasted the table as values and removed all links to the underlying data. Very helpful.</p>
<p> Yesterday I had to deal with a data file that looked a little like this only  it spread out across 455 columns and was frankly useless.</p>
<p style="text-align: center;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab1.gif"></a></p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab2.gif"></a></p>
<p style="text-align: center;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab2a.gif"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="size-full wp-image-1867  aligncenter" title="crosstab2a" src="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab2a.gif" alt="" width="496" height="142" /></a></p>
<p style="text-align: left;">I wrote a post a while back that demonstrated <a href="http://whatapalaver.co.uk/2009/07/excel-crosstab-table-to-flat-list/">how to convert a simple cross tab back to a manageable data list</a> but I wanted to expand this with a slightly more complex example which had more field headings.</p>
<p>So starting with the table above which was probably a pasted copy from a pivot table I applied a little bit of formatting to achieve the following starting table.</p>
<p style="text-align: center;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab2b.gif"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-1868" title="crosstab2b" src="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab2b.gif" alt="" width="519" height="149" /></a></p>
<p>What I have done is remove the grouping that the pivot table applies and ensured that I have the relevant  week number, project and department details against each name</p>
<p>I often wish to convert pivot table outputs back into a data file and the way I fill in the blanks caused by grouping data is to prepare a sheet with formulas that copy values from above (or the side as appropriate):</p>
<p style="text-align: center;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab2c.gif"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-1869" title="crosstab2c" src="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab2c.gif" alt="" width="472" height="166" /></a></p>
<p> </p>
<p>I then copy the pivot table data and then use the paste special command selecting paste values and skip blanks as the options.</p>
<p style="text-align: center;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/CROSSTAB1C.jpg"></a></p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab3.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-1870" title="crosstab3" src="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab3.jpg" alt="" width="490" height="371" /></a>This results in the following output, which I then copy and paste over itself as values, to give me the desired structure.</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab4.gif"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-1871" title="crosstab4" src="http://whatapalaver.co.uk/wp-content/uploads/2010/07/crosstab4.gif" alt="" width="490" height="160" /></a></p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/CROSSTAB1B.jpg"></a></p>
<p>Having spent a bit of time on the structure of my starting file I can run the macro that will work through each row and transpose the data from a columnar layout to one based on rows.</p>
<p>The advantage of this format is that I can now create my own pivot tables and cut the data as I see fit to produce multiple summary formats according to my audience.</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/CROSSTAB1C.jpg"></a></p>
<p style="text-align: center;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/FLATLIST.jpg"></a></p>
<p><span style="color: #000000;"><a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/flatlist1.gif"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-1873" title="flatlist1" src="http://whatapalaver.co.uk/wp-content/uploads/2010/07/flatlist1.gif" alt="" width="505" height="577" /></a></span></p>
<p><span style="color: #000000;">Here&#8217;s the macro I use:</span></p>
<blockquote><p><strong>Sub CrossTabToList()</strong></p>
<p>Dim wsCrossTab As Worksheet<br />
Dim wsList As Worksheet<br />
Dim iLastCol As Long<br />
Dim iLastRow As Long<br />
Dim iLastRowList As Long<br />
Dim rngCTab As Range &#8216;Used for range in Sheet1 cross tab sheet<br />
Dim rngList As Range &#8216;Destination range for the list<br />
Dim ROW As Long</p>
<p>Set wsCrossTab = Worksheets(&#8220;Sheet1&#8243;) <span style="color: #008000;">&#8216;AMEND TO SHOW SHEET NUMBER WITH THE CROSS </span>TAB<br />
Set wsList = Worksheets.Add</p>
<p><span style="color: #008000;">&#8216;Find the last row in Sheet1 with the cross tab</span><br />
iLastRow = wsCrossTab.Cells(Rows.Count, &#8220;A&#8221;).End(xlUp).ROW</p>
<p><span style="color: #008000;">&#8216;Set the initial value for the row in the destination worksheet</span><br />
iLastRowList = 2</p>
<p><span style="color: #008000;">&#8216;Find the last column in Sheet1 with the cross tab<br />
</span>iLastCol = wsCrossTab.Range(&#8220;A2&#8243;).End(xlToRight).Column</p>
<p><span style="color: #008000;">&#8216;SET THE HEADING TITLES IN THE LIST SHEET<br />
</span>wsList.Range(&#8220;A1:F1&#8243;) = Array(&#8220;NAME&#8221;, &#8220;PROJECT&#8221;, &#8220;TYPE&#8221;, &#8220;PLAN/ACTUAL&#8221;, &#8220;WEEK&#8221;, &#8220;HOURS&#8221;)</p>
<p><span style="color: #008000;">&#8216;Start looping through the cross tab data</span></p>
<p>For ROW = 3 To iLastRow <span style="color: #008000;">&#8216;START AT ROW 3 AS THIS IS WHERE DATA BEGINS</span><br />
Set rngCTab = wsCrossTab.Range(&#8220;A&#8221; &amp; ROW, &#8220;C&#8221; &amp; ROW) <span style="color: #008000;">&#8216;initial value A3 SETS THE RANGE TO</span></p>
<p><span style="color: #008000;">&#8216;INCLUDE ALL STATIC DATA &#8211; IN THIS CASE NAME, PROJECT, TYPE<br />
</span>Set rngList = wsList.Range(&#8220;A&#8221; &amp; iLastRowList) &#8216;initial value A3</p>
<p><span style="color: #008000;">&#8216;Copy individual names in Col A (A3 initially) into as many rows as there are data columns</span><br />
<span style="color: #008000;">&#8216;in the cross tab (less 3 for Col A-C).</span><br />
rngCTab.Copy rngList.Resize(iLastCol &#8211; 3)</p>
<p><span style="color: #008000;">&#8216;SELECT THE HEADING ROW WITH FORECAST/ACTUAL<br />
&#8216;Move up ROW (INITIALLY 3) rows less TWO and across 3 columns (using offset function). Copy.<br />
</span>rngCTab.Offset(-(ROW &#8211; 2), 3).Resize(, iLastCol &#8211; 3).Copy</p>
<p><span style="color: #008000;">&#8216;Paste transpose to columns in the list sheet alongside the static data<br />
</span>rngList.Offset(0, 3).PasteSpecial Transpose:=True</p>
<p><span style="color: #008000;">&#8216;SELECT THE ROW WITH THE WEEK NUMBERS<br />
</span><span style="color: #008000;">&#8216;Move up ROW (INITIALLY 3) rows less ONE and across 3 columns (using offset function). Copy.<br />
</span>rngCTab.Offset(-(ROW &#8211; 1), 3).Resize(, iLastCol &#8211; 3).Copy</p>
<p><span style="color: #008000;">&#8216;Paste transpose to columns in the list sheet alongside the static data<br />
</span>rngList.Offset(0, 4).PasteSpecial Transpose:=True</p>
<p><span style="color: #008000;">&#8216;Staying on same row (3 initially) copy the data from the cross tab</span><br />
rngCTab.Offset(, 3).Resize(, iLastCol &#8211; 3).Copy</p>
<p><span style="color: #008000;">&#8216;Past transpose as column in list sheet</span><br />
rngList.Offset(0, 5).PasteSpecial Transpose:=True</p>
<p><span style="color: #008000;">&#8216;Set the new last row in list sheet to be just below the last name copied</span><br />
iLastRowList = iLastRowList + (iLastCol &#8211; 3)</p>
<p><span style="color: #008000;">&#8216;increment ROW by 1</span><br />
Next ROW</p>
<p><strong>End Sub</strong></p></blockquote>
<p>I&#8217;m afraid the VBA code isn&#8217;t rendering very well &#8211; you&#8217;ll have to replace all the &#8221; and &#8216; marks before the macro editor will recognise the code.<br />
Here is a copy of file &#8211; you could copy the macro code from here: <a href="http://whatapalaver.co.uk/wp-content/uploads/2010/07/Excel-to-CrossTab.xls">Excel to CrossTab.xls</a></p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2010/07/excel-pivot-table-or-crosstab-to-flat-list/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>VBA Snippets &#8211; Sorting Arrays and Random Selection</title>
		<link>http://whatapalaver.co.uk/2010/01/vba-snippets-sorting-arrays-and-random-selection/</link>
		<comments>http://whatapalaver.co.uk/2010/01/vba-snippets-sorting-arrays-and-random-selection/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 16:24:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=1533</guid>
		<description><![CDATA[The blog post sounds a little Darwinian but I&#8217;m afraid it&#8217;s just a dull selection of VBA code that enables you to sort one array on the basis of values from another. A double sorting array. I&#8217;ve amended array sorting code from John Walkenbach and Anthony&#8217;s VBA Tutorials to create something I can understand. The [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F01%2Fvba-snippets-sorting-arrays-and-random-selection%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F01%2Fvba-snippets-sorting-arrays-and-random-selection%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The blog post sounds a little Darwinian but I&#8217;m afraid it&#8217;s just a dull selection of VBA code that enables you to sort one array on the basis of values from another. A double sorting array.</p>
<p>I&#8217;ve amended array sorting code from John Walkenbach and <a href="http://www.anthony-vba.kefra.com/vba/excelvba-simulation.htm#Creating_and_Managing_Array" rel="nofollow" >Anthony&#8217;s VBA Tutorials</a> to create something I can understand.</p>
<p>The DbleBubbleSort routine takes two arrays as arguments and sorts the string array (y) on the basis of the values in a nuber array (x). I&#8217;m using John Walkenbachs BubbleSort methodology which is simple but undoubtedly not the most efficient.</p>
<blockquote><p><strong>Sub DbleBubbleSort(x() As Single, y() As String)</strong></p>
<p><span style="color: #339966;">&#8216; adapting the BubbleSort method to sort an array on the basis of the values in another array.<br />
&#8216; x is an array of numbers (can be random as in the DbleSortTest() routine)<br />
&#8216; y is a string array</span><br />
    Dim First As Integer, Last As Long<br />
    Dim i As Long, j As Long<br />
    Dim xtemp As Single<br />
    Dim ytemp As String<br />
   <br />
    First = LBound(x)<br />
    Last = UBound(x)<br />
    For i = First To Last &#8211; 1<br />
        For j = i + 1 To Last<br />
            If x(i) &gt; x(j) Then<br />
                xtemp = x(j)<br />
                ytemp = y(j)<br />
                x(j) = x(i)<br />
                y(j) = y(i)<br />
                x(i) = xtemp<br />
                y(i) = ytemp<br />
            End If<br />
        Next j<br />
    Next i<br />
<strong>End Sub</strong></p></blockquote>
<p>The following routine calls on the DbleBubbleSort sub routine and uses it to provide a random selection of 3 entries from a string array.</p>
<blockquote><p><strong>Sub DbleSortTest()<br />
</strong><span style="color: #339966;">&#8216;this is an amended version of a function on </span><a href="http://www.anthony-vba.kefra.com/vba/excelvba-simulation.htm#Creating_and_Managing_Array" rel="nofollow" ><span style="color: #0000ff;">http://www.anthony-vba.kefra.com/vba/excelvba-simulation.htm#Creating_and_Managing_Array</span></a><br />
<span style="color: #339966;">&#8216;it randomly selects 3 entries from a text array (y)<br />
&#8216;it utilises a random number array and the sorting of one array based on the values in another.</span></p>
<p>    Dim i As Long<br />
    Dim x(8) As Single, y(8) As String<br />
    Dim str As String</p>
<p>    y(1) = &#8220;Anthony&#8221;<br />
    y(2) = &#8220;Bobby&#8221;<br />
    y(3) = &#8220;Chris&#8221;<br />
    y(4) = &#8220;Danny&#8221;<br />
    y(5) = &#8220;Eton&#8221;<br />
    y(6) = &#8220;Frank&#8221;<br />
    y(7) = &#8220;George&#8221;<br />
    y(8) = &#8220;Harry&#8221;<br />
   <br />
   <span style="color: #339966;"> &#8216;enters the x array into a worksheet<br />
</span>    For i = 1 To UBound(x)<br />
        x(i) = Rnd<br />
        Cells(i, 2) = x(i)<br />
    Next i<br />
   <br />
  <span style="color: #339966;">  &#8216;enters the y array in column 3 of the worksheet</span><br />
    For i = 1 To UBound(y)<br />
        Cells(i, 3) = y(i)<br />
    Next i<br />
   <br />
    Call DbleBubbleSort(x, y)<br />
   <br />
   <span style="color: #339966;"> &#8216;calls the first 3 values of y sorted according to x and enters them in the worksheet<br />
</span>    str = &#8220;&#8221;<br />
    For i = 1 To 3<br />
        str = str &amp; y(i) &amp; vbCrLf<br />
        Cells(i, 1) = y(i)<br />
    Next i</p>
<p>    MsgBox str<br />
<strong>End Sub</strong></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2010/01/vba-snippets-sorting-arrays-and-random-selection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBA Snippets to Sort Arrays in VBA</title>
		<link>http://whatapalaver.co.uk/2010/01/vba-snippets-to-sort-arrays-in-vba/</link>
		<comments>http://whatapalaver.co.uk/2010/01/vba-snippets-to-sort-arrays-in-vba/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 14:54:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=1526</guid>
		<description><![CDATA[Here&#8217;s another VBA snippet post. I find it handy to have a store of regularly used macros on the blog so I can access them at any time, not that I need them that often of course. These particular snippets are useful routines for sorting arrays and can be called from other procedures. I&#8217;ve taken [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F01%2Fvba-snippets-to-sort-arrays-in-vba%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2010%2F01%2Fvba-snippets-to-sort-arrays-in-vba%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Here&#8217;s another VBA snippet post. I find it handy to have a store of regularly used macros on the blog so I can access them at any time, not that I need them that often of course.</p>
<p>These particular snippets are useful routines for sorting arrays and can be called from other procedures. I&#8217;ve taken these particular ones from John Walkenbach&#8217;s book: Excel 2007 Power Programming with VBA. I&#8217;m working my way through <a href="http://www.anthony-vba.kefra.com/" rel="nofollow" >Anthony&#8217;s VBA tutorials</a> for excel modelling and array sorting is regular feature.</p>
<p>The BubbleSort code is easy to understand and therefore one of my favourites but the other 3 methods are much quicker for arrays with more than 500 entries.</p>
<blockquote><p><strong>Sub BubbleSort(list() As String)</strong><br />
<span style="color: #339966;">&#8216; Taken from power programming with VBA<br />
&#8216; It&#8217;s a sorting procedure for 1-dimensional arrays named List<br />
&#8216; The procedure takes each array element, if it is greater than the next element, the two elements swap positions.<br />
&#8216; The evaluation is repeated for every pair of items (that is n-1 times)<br />
&#8216; Change data type to As Integer if your array isn&#8217;t text</span><br />
    Dim First As Integer, Last As Long<br />
    Dim i As Long, j As Long<br />
    Dim temp As String<br />
    First = LBound(list)<br />
    Last = UBound(list)<br />
    For i = First To Last &#8211; 1<br />
        For j = i + 1 To Last<br />
            If list(i) &gt; list(j) Then<br />
                temp = list(j)<br />
                list(j) = list(i)<br />
                list(i) = temp<br />
            End If<br />
        Next j<br />
    Next i<br />
<strong>End Sub</strong></p></blockquote>
<p>You can test this macro with the following routine which pastes the results into the immediate window.</p>
<blockquote><p><strong>Sub SortTester()<br />
</strong>   <br />
    Dim x(1 To 5) As String<br />
    Dim i As Long<br />
   <br />
    x(1) = &#8220;egg&#8221;<br />
    x(2) = &#8220;apple&#8221;<br />
    x(3) = &#8220;stuff&#8221;<br />
    x(4) = &#8220;nonsense&#8221;<br />
    x(5) = &#8220;1&#8243;<br />
   <br />
    Call BubbleSort(x)<br />
   <br />
    For i = 1 To 5<br />
        Debug.Print i, x(i)<br />
    Next i<br />
<strong>End Sub</strong></p></blockquote>
<p>Here are a few more sort options which are a bit more efficient but unfortunately more complex.</p>
<blockquote><p><strong>Sub WorksheetSort(list)<br />
</strong><span style="color: #339966;">&#8216;   Sorts an array by transferring it to<br />
&#8216;   A worksheet and using Excel&#8217;s sorting command<br />
</span>   <br />
    Dim First As Integer, Last As Long<br />
    Dim i As Long<br />
    Dim FirstCell As Range, LastCell As Range<br />
    Dim CurrCell As Range, FillRange As Range<br />
   <br />
    First = LBound(list, 1)<br />
    Last = UBound(list, 1)<br />
    Set FirstCell = Sheets(&#8220;Sheet1&#8243;).Cells(1, 1)<br />
    Set LastCell = Sheets(&#8220;Sheet1&#8243;).Cells(Last, 1)<br />
    Set FillRange = Range(FirstCell, LastCell)<br />
    Application.ScreenUpdating = False<br />
   <br />
<span style="color: #339966;">&#8216;   Transfer the array to worksheet<br />
</span>    FillRange.Value = list<br />
   <br />
<span style="color: #339966;">&#8216;   Sort the worksheet range<br />
</span>    FirstCell.CurrentRegion.Sort Key1:=FirstCell, Order1:=xlAscending, Orientation:=xlTopToBottom<br />
      <br />
<span style="color: #339966;">&#8216;   Transfer range back to the array and clear range<br />
</span>    For i = First To Last<br />
        list(i, 0) = FirstCell.Offset(i &#8211; 1, 0)<br />
    Next i<br />
    FillRange.Clear<br />
    Application.ScreenUpdating = True<br />
<strong>End Sub</strong></p>
<p><strong>Public Sub Quicksort(list() As Long, ByVal min As Long, ByVal max As Long)  </strong><br />
<span style="color: #339966;">&#8216;This technique works only with Integer or Long values.</span><br />
Dim med_value As Long<br />
    Dim hi As Long<br />
    Dim lo As Long<br />
    Dim i As Long</p>
<p>   <span style="color: #339966;"> &#8216; If min &gt;= max, the list contains 0 or 1 items so it<br />
    &#8216; is sorted.<br />
</span>    If min &gt;= max Then Exit Sub</p>
<p>  <span style="color: #339966;">  &#8216; Pick the dividing value.<br />
</span>    i = Int((max &#8211; min + 1) * Rnd + min)<br />
    med_value = list(i)</p>
<p> <span style="color: #339966;">   &#8216; Swap it to the front.<br />
</span>    list(i) = list(min)</p>
<p>    lo = min<br />
    hi = max<br />
    Do<br />
      <span style="color: #339966;">  &#8216; Look down from hi for a value &lt; med_value.<br />
</span>        Do While list(hi) &gt;= med_value<br />
            hi = hi &#8211; 1<br />
            If hi &lt;= lo Then Exit Do<br />
        Loop<br />
        If hi &lt;= lo Then<br />
            list(lo) = med_value<br />
            Exit Do<br />
        End If</p>
<p>       <span style="color: #339966;"> &#8216; Swap the lo and hi values.<br />
</span>        list(lo) = list(hi)<br />
       <br />
       <span style="color: #339966;"> &#8216; Look up from lo for a value &gt;= med_value.<br />
</span>        lo = lo + 1<br />
        Do While list(lo) &lt; med_value<br />
            lo = lo + 1<br />
            If lo &gt;= hi Then Exit Do<br />
        Loop<br />
        If lo &gt;= hi Then<br />
            lo = hi<br />
            list(hi) = med_value<br />
            Exit Do<br />
        End If<br />
       <br />
       <span style="color: #339966;"> &#8216; Swap the lo and hi values.<br />
</span>        list(hi) = list(lo)<br />
    Loop<br />
   <br />
    <span style="color: #339966;">&#8216; Sort the two sublists.<br />
</span>    Quicksort list(), min, lo &#8211; 1<br />
    Quicksort list(), lo + 1, max<br />
<strong>End Sub</strong></p>
<p><strong>Sub Countingsort(list)</strong><br />
<span style="color: #339966;">&#8216;This technique works only with Integer or Long values.</span><br />
Dim counts()<br />
    Dim i As Long<br />
    Dim j As Long<br />
    Dim next_index As Long<br />
    Dim min, max<br />
    Dim min_value As Variant, max_value As Variant</p>
<p><span style="color: #339966;">&#8216;   Allocate the counts array. VBA automatically<br />
&#8216;   initialises all entries to 0.</span></p>
<p>    min_value = Minimum(list)<br />
    max_value = Maximum(list)</p>
<p>    min = LBound(list)<br />
    max = UBound(list)<br />
   <br />
    ReDim counts(min_value To max_value)<br />
   <br />
<span style="color: #339966;">    &#8216; Count the values.<br />
</span>    For i = min To max<br />
        counts(list(i)) = counts(list(i)) + 1<br />
    Next i</p>
<p>   <span style="color: #339966;"> &#8216; Write the items back into the list array.<br />
</span>    next_index = min<br />
    For i = min_value To max_value<br />
        For j = 1 To counts(i)<br />
            list(next_index) = i<br />
            next_index = next_index + 1<br />
        Next j<br />
    Next i<br />
<strong>End Sub</strong></p>
<p><strong>Function Minimum(list)<br />
</strong>    Dim i As Long<br />
    Minimum = list(LBound(list))<br />
    For i = LBound(list) To UBound(list)<br />
        If list(i) &lt; Minimum Then Minimum = list(i)<br />
    Next i<br />
<strong>End Function</strong></p>
<p><strong>Function Maximum(list)<br />
</strong>    Dim i As Long<br />
    Maximum = list(LBound(list))<br />
    For i = LBound(list) To UBound(list)<br />
        If list(i) &gt; Maximum Then Maximum = list(i)<br />
    Next i<br />
<strong>End Function</strong></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2010/01/vba-snippets-to-sort-arrays-in-vba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBA Snippets to Delete Rows in Excel</title>
		<link>http://whatapalaver.co.uk/2009/09/vba-snippets-to-delete-rows-in-excel/</link>
		<comments>http://whatapalaver.co.uk/2009/09/vba-snippets-to-delete-rows-in-excel/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 15:21:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[delete rows]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=1059</guid>
		<description><![CDATA[I regularly use simple macros to delete blank rows in my excel spreadsheets and there are loads of examples on internet forums. I&#8217;ve recently had to recreate these delete row macros to install on a new computer and thought it would be useful to keep them filed here on the blog. This first macro will [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2009%2F09%2Fvba-snippets-to-delete-rows-in-excel%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2009%2F09%2Fvba-snippets-to-delete-rows-in-excel%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I regularly use simple macros to delete blank rows in my excel spreadsheets and there are loads of examples on internet forums.</p>
<p style="float: right; margin-left: 10px; margin-bottom: 10px"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-1062" title="Screen shot 2009-09-05 at 15.59.57" src="http://whatapalaver.co.uk/wp-content/uploads/2009/09/Screen-shot-2009-09-05-at-15.59.57.png" alt="Screen shot 2009-09-05 at 15.59.57" width="236" height="173" /></p>
<p>I&#8217;ve recently had to recreate these delete row macros to install on a new computer and thought it would be useful to keep them filed here on the blog.</p>
<p>This first macro will delete any row in which the cell in the selected column is blank. So in this example, with column B selected, rows 4 &amp; 7 will be deleted.</p>
<blockquote><p><strong>Sub DeleteRowOnBlankCell()</strong></p>
<p style="padding-left: 30px;"><span style="color: #008000;">&#8216;Deletes entire row within the selected column where cell within selection is blank</span></p>
<p style="padding-left: 30px;"><span style="color: #008000;"> ‘Select column then run the macro</span></p>
<p style="padding-left: 60px;">On Error Resume Next</p>
<p style="padding-left: 90px;">Selection.EntireRow.SpecialCells(xlBlanks).EntireRow.Delete</p>
<p style="padding-left: 60px;">On Error GoTo 0</p>
<p style="padding-left: 60px;">
<p style="padding-left: 60px;">
<p><strong>End Sub</strong></p></blockquote>
<p>The following macro will only delete rows if the entire row is blank. Just select the area you want to evaluate and run the macro.</p>
<blockquote><p><strong>Sub DeleteBlankRows()</strong></p></blockquote>
<blockquote>
<p style="padding-left: 30px;"><span style="color: #008000;">&#8216;Deletes the entire row within the selection provided the ENTIRE row is blank.</span></p>
<p style="padding-left: 30px;"><span style="color: #008000;">Dim i As Long</span></p>
<p style="padding-left: 60px;">For i = Selection.Rows.Count To 1 Step -1</p>
<p style="padding-left: 90px;">If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then</p>
<p style="padding-left: 120px;">Selection.Rows(i).EntireRow.Delete</p>
<p style="padding-left: 90px;">End If</p>
<p style="padding-left: 60px;">Next i</p>
<p style="padding-left: 60px;">
<p style="padding-left: 60px;">
</blockquote>
<blockquote><p><strong>End Sub</strong></p></blockquote>
<p>To use these macros just copy and paste them into a module within your personal macro workbook (press ALT F11 to open the VBA editor) which will make them available for use whenever excel is open. Sometimes the personal workbook doesn&#8217;t show up in the VBA editor and if this is the case I just record a new macro, select the option to save it in the personal workbook, make a few changes to a spreadsheet and stop recording. This will have the effect of creating a new module in  personal.xls, along with a fairly useless macro that can now be deleted.</p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2009/09/vba-snippets-to-delete-rows-in-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conditional Ranking in Excel &#8211; RankIF using SumProduct</title>
		<link>http://whatapalaver.co.uk/2009/09/conditional-ranking-in-excel-rankif-using-sumproduct/</link>
		<comments>http://whatapalaver.co.uk/2009/09/conditional-ranking-in-excel-rankif-using-sumproduct/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 10:16:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[RANKIF]]></category>
		<category><![CDATA[Sumproduct]]></category>

		<guid isPermaLink="false">http://whatapalaver.co.uk/?p=1053</guid>
		<description><![CDATA[I was hunting around for a RANKIF function yesterday so I could rank a load of hospitals in terms of their cost per procedure. Unfortunately RANKIF isn’t one of the available functions but I managed to achieve the same effect by utilising the SUMPRODUCT function. I wrote a SUMPRODUCT tutorial some time ago indicating how [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2009%2F09%2Fconditional-ranking-in-excel-rankif-using-sumproduct%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2009%2F09%2Fconditional-ranking-in-excel-rankif-using-sumproduct%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I was hunting around for a RANKIF function yesterday so I could rank a load of hospitals in terms of their cost per procedure.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-1054" title="RankIF" src="http://whatapalaver.co.uk/wp-content/uploads/2009/09/RankIF.jpg" alt="RankIF" width="422" height="305" /></p>
<p>Unfortunately RANKIF isn’t one of the available functions but I managed to achieve the same effect by utilising the SUMPRODUCT function.</p>
<p>I wrote a <a href="http://whatapalaver.co.uk/2007/09/sumproduct/">SUMPRODUCT tutorial</a> some time ago indicating how the powerful function can act as a multi conditioned SUMIF formula but it seems it can also act as a multi conditioned RANKIF formula as well.</p>
<p>The formula I used to achieve the above ranking was:</p>
<p>=1+SUMPRODUCT(($B$2:$B$12=B2)*($C$2:$C$12&gt;C2))</p>
<p>Copied down the column it will return the number of organisations for a given procedure which have costs higher than the selected row. Adding 1 to the result just ensures that the highest cost organisation starts with a rank of 1 rather than 0.</p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2009/09/conditional-ranking-in-excel-rankif-using-sumproduct/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Excel CrossTab Table to Flat List</title>
		<link>http://whatapalaver.co.uk/2009/07/excel-crosstab-table-to-flat-list/</link>
		<comments>http://whatapalaver.co.uk/2009/07/excel-crosstab-table-to-flat-list/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 12:23:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Geeky Corner]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[Pivot Table]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[used range]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.angelawolff.co.uk/Excel/stream/archives/62</guid>
		<description><![CDATA[I had a query on my sumproduct tutorial that was effectively asking if I could work backwards from an excel crosstab or data table to get back to the simple flat list. Converting a table like this: Back to the data sheet like this: If you didn’t have to do this sort of task very [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2009%2F07%2Fexcel-crosstab-table-to-flat-list%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwhatapalaver.co.uk%2F2009%2F07%2Fexcel-crosstab-table-to-flat-list%2F&amp;source=warriorwoman&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I had a query on my <a href="http://www.angelawolff.co.uk/Excel/stream/2007/09/27/sumproduct/" rel="nofollow" >sumproduct tutorial</a> that was effectively asking if I could work backwards from an excel crosstab or data table to get back to the simple flat list.</p>
<p>Converting a table like this:</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2007/09/sumproduct31.gif"title="sumproduct" ><img src="http://whatapalaver.co.uk/wp-content/uploads/2007/09/sumproduct31.gif" alt="sumproduct" /></a></p>
<p>Back to the data sheet like this:</p>
<p><a href="http://whatapalaver.co.uk/wp-content/uploads/2007/09/sumproduct11.gif"title="sumproduct" ><img src="http://whatapalaver.co.uk/wp-content/uploads/2007/09/sumproduct11.gif" alt="sumproduct" /></a></p>
<p>If you didn’t have to do this sort of task very often you could get by with a pivot table solution and a few stages of formatting but it would only work if your data values were numbers that could be summed in the pivot.</p>
<p>If you need to convert Excel data tables (or crosstabs) into flat lists on a regular basis then you will need a macro.</p>
<p>I have prepared a workbook that demonstrates both the pivot table and macro solution and you can download it from here:<br />
<a href="http://whatapalaver.co.uk/wp-content/uploads/2009/07/crosstab-to-list-macro1.xls"title="Excel Table to Flat List" >ExcelTabletoFlatList.xls</a></p>
<p>The following macro does the trick and utilises the VBA I introduced in my <a href="http://www.angelawolff.co.uk/Excel/stream/2009/07/24/macros-to-consolidate-worksheets/" rel="nofollow" >last post on consolidating worksheets,</a> to determine the last used row and last used column.</p>
<p>Sub CrossTabToList()</p>
<p>Dim wsCrossTab As Worksheet<br />
Dim wsList As Worksheet<br />
Dim iLastCol As Long<br />
Dim iLastRow As Long<br />
Dim iLastRowList As Long<br />
Dim rngCTab As Range <span style="color: green;">&#8216;Used for range in Sheet1 cross tab sheet</span><br />
Dim rngList As Range <span style="color: green;">&#8216;Destination range for the list</span><br />
Dim I As Long</p>
<p>Set wsCrossTab = Worksheets(&#8220;Sheet1&#8243;)<br />
Set wsList = Worksheets.Add</p>
<p><span style="color: green;">&#8216;Find the last row in Sheet1 with the cross tab</span><br />
iLastRow = wsCrossTab.Cells(Rows.Count, &#8220;A&#8221;).End(xlUp).Row</p>
<p><span style="color: green;">&#8216;Set the initial value for the row in the destination worksheet</span><br />
iLastRowList = 2</p>
<p><span style="color: green;">&#8216;Find the last column in Sheet1 with the cross tab</span><br />
iLastCol = wsCrossTab.Range(&#8220;A1&#8243;).End(xlToRight).Column</p>
<p><span style="color: green;">&#8216;Create a new sheet and set the heading titles</span><br />
wsList.Range(&#8220;A1:C1&#8243;) = Array(&#8220;NAME&#8221;, &#8220;GRADE&#8221;, &#8220;VALUE&#8221;)</p>
<p><span style="color: green;">&#8216;Start looping through the cross tab data</span></p>
<p>For I = 2 To iLastRow</p>
<p>Set rngCTab = wsCrossTab.Range(&#8220;A&#8221; &amp; I) <span style="color: green;">&#8216;initial value A2</span><br />
Set rngList = wsList.Range(&#8220;A&#8221; &amp; iLastRowList) <span style="color: green;">&#8216;initial value A2</span></p>
<p><span style="color: green;">&#8216;Copy individual names in Col A (A2 initially) into as many rows as there are data columns</span><br />
<span style="color: green;">&#8216;in the cross tab (less 1 for Col A). </span><br />
rngCTab.Copy rngList.Resize(iLastCol &#8211; 1)</p>
<p><span style="color: green;">&#8216;Move up a I rows less one and across one column (using offset function) to select heading row. Copy. </span><br />
rngCTab.Offset(-(I &#8211; 1), 1).Resize(, iLastCol &#8211; 1).Copy</p>
<p><span style="color: green;">&#8216;Paste transpose to columns in the list sheet alongside the names</span><br />
rngList.Offset(0, 1).PasteSpecial Transpose:=True</p>
<p><span style="color: green;">&#8216;Staying on same row (2 initially) copy the data from the cross tab</span><br />
rngCTab.Offset(, 1).Resize(, iLastCol &#8211; 1).Copy</p>
<p><span style="color: green;">&#8216;Past transpose as column in list sheet</span><br />
rngList.Offset(0, 2).PasteSpecial Transpose:=True</p>
<p><span style="color: green;">&#8216;Set the new last row in list sheet to be just below the last name copied</span><br />
iLastRowList = iLastRowList + (iLastCol &#8211; 1)</p>
<p><span style="color: green;">&#8216;increment I by 1</span><br />
Next I</p>
<p>End Sub</p>
]]></content:encoded>
			<wfw:commentRss>http://whatapalaver.co.uk/2009/07/excel-crosstab-table-to-flat-list/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.598 seconds -->

