My RSS Feed https://www.childs.be/plugins/gs-blog/rss.php Welcome to my blog!! Mon, 16 Jun 2025 13:25:16 +0100 en-gb A datedif function for excel that calculates correctly Sat, 15 Apr 2017 08:00:00 +0100 https://www.childs.be/articles/post/a-datedif-function-for-excel-that-calculates-correctly https://www.childs.be/articles/post/a-datedif-function-for-excel-that-calculates-correctly This is one of those little quirks in excel that's annoyed me for a while, there must be some method in their madness but I've yet to come across anybody that thinks it is logically the way forward; so I've written one for you to use. The way the in-built function works is that it reports back the answer as how many months apart are the two dates <p><strong>This is one of those little quirks in excel that&#39;s annoyed me for a while, there must be some method in their madness but I&#39;ve yet to come across anybody that thinks it is logically the way forward; so I&#39;ve written one for you to use.</strong></p> <p>The way the in-built function works is that it reports back the answer as how many months apart are the two dates so regardless of the day in the month they fall, any date in May vs any date in June the answer will be one.</p> <p>Can&#39;t actually think of any real world use of this as always want to know how many full months are bewteen the two dates. For example 23-June vs 1-July is less than one month away so 0; 23-June vs 27-July would give 1. Contrast this to the excel way and you&#39;d get the answer of 1 for both.</p> <p>So explanation over we&#39;ll give give you the code, head over to the VBA editor (Alt-F11), insert...module then paste the code in:</p> <pre>Function DateDifm(Date1 As Date, Date2 As Date) As Date &#39; ===================================================================================== &#39; Author: Martin Childs &#39; Create date: 2017-03-08 &#39; Description: Returns correct date difference in months for given inputs &#39; ===================================================================================== DateDifm = DateDiff(&quot;m&quot;, Date1 - Day(Date1) + 1, Date2 - Day(Date1) + 1) End Function</pre> <p>When you completed that head back into excel and you can use the formula:</p> <p>=DateDifm(A1,B1)</p> <h3>Without VBA option</h3> <p>If you don&#39;t want to use VBA, heres how you can do it straight in an excel formula, in this example the two dates we are comparing are in A1 and A2:</p> <pre>= DATEDIF( EOMONTH(A1,-1)+1, B1-DAY(A1)+1, &quot;m&quot;)</pre> <p>I&#39;ve slightly re-written it compared to the VBA function above to have less linking within the formula, but you can do it this way also:</p> <pre>= DATEDIF( A1-DAY(A1)+1, B1-DAY(A1)+1, &quot;m&quot;)</pre> <h3>SQL equivalent</h3> <p>The correct way of calculating it came about when I was performing a critical calculation in SQL and in the back of my mind it was nagging me whether, as they are both from Microsoft, the DATEDIFF() function in T-SQL had the same flaw. My suspisions were correct - both calculate in the same way, but from the same post on <a href="http://stackoverflow.com/questions/1106945/calculating-number-of-full-months-between-two-dates-in-sql">StackOverflow </a>I had noticed a very efficient craft bit of code which was so much shorter than everything else and from here went on to adapt it into VBA.</p> <p>Here the SQL function if you are also interested:</p> <pre>IF OBJECT_ID (N&#39;dbo.DateDiffm&#39;, N&#39;FN&#39;) IS NOT NULL DROP FUNCTION dbo.DateDiffm; GO -- ================================================================================== -- Author: Martin Childs -- Create date: 2017-01-23 -- Description: Returns correct date difference in months for given inputs -- Version: v001 -- ================================================================================== CREATE FUNCTION dbo.DateDiffm( @Date1 as datetime, @Date2 as datetime ) RETURNS int AS BEGIN Return ( datediff(month, dateadd(day,-day(@Date1)+1,@Date1),dateadd(day,-day(@Date1)+1,@Date2)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) END;</pre> <p>&nbsp;</p> Excel excel,function,datedif,datediff,sql Create custom Excel function using an array/range input Thu, 30 Mar 2017 08:00:00 +0100 https://www.childs.be/articles/post/create-custom-excel-function-using-an-arrayrange-input https://www.childs.be/articles/post/create-custom-excel-function-using-an-arrayrange-input My new adage of "You only know what you know how to google" - Martin Childs, 2016 stood true for this little puzzler, the answer wasn't apparent from simply googling it! All I wanted was to do something to a range input in a custom Excel function, easy you'd think - not in this case. I toiled for a bit of time before conceding that I'd just have <p>My new adage of</p> <blockquote><big>&quot;<a href="https://www.childs.be/blog/post/you-only-know-what-you-know-how-to-google">You only know what you know <em>how </em>to google</a>&quot;</big><br /> - Martin Childs, 2016</blockquote> <p>stood true for this little puzzler, the answer wasn&#39;t apparent from simply googling it! All I wanted was to do something to a range input in a custom Excel function, easy you&#39;d think - not in this case. I toiled for a bit of time before conceding that I&#39;d just have to work it out from first principles.</p> <p>First up it is properly referred to as an <code>array</code> rather than a <code>range</code> - range refers just to the cell reference rather than the contents of the range. To be able to use inputted range you need to determine a variable as an array of some type and then read all the possible cells in the range into it:</p> <pre>Dim MyArray() as Variant MyArray = InputRange</pre> <p>Now we are rocking, next up is referencing it - <code>LBound</code> &amp; <code>UBound</code> are your friends here, used quite universally in a lot of programming languages - they find the outer extremities of your array and allow you to loop through all the values. The next bit also foxed my for a short time - I could only read in one row with</p> <pre>for i = LBound(MyAr1, 2) To UBound(MyAr1, 2)</pre> <p>But why was it it two - well to get a two dimensional array working you have to loop both the 1 and the 2. Now we just have to hook it all together and loop through all the references and read the values, in this example I just complete a simple sum with the function:</p> <pre>Function mySum(input1 As Range) As Variant &#39; &#39; www.childs.be, 2017-02-04 &#39; &nbsp;&nbsp;&nbsp; Dim MyAr1() As Variant &nbsp;&nbsp;&nbsp; MyAr1 = input1 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; For j = LBound(MyAr1, 1) To UBound(MyAr1, 1) &nbsp;&nbsp;&nbsp; For i = LBound(MyAr1, 2) To UBound(MyAr1, 2) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If IsNumeric(input1(j,i)) = True Then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; N = N + input1(j, i) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If &nbsp;&nbsp;&nbsp; Next i &nbsp;&nbsp;&nbsp; Next j &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mySum = N End Function</pre> <p>&nbsp;</p> Excel excel,function,range,custom Excel: How to calculate distances between longitude / latitude co-ordinates Sun, 26 Feb 2017 20:00:00 +0000 https://www.childs.be/articles/post/excel-how-to-calculate-distances-between-longitude-latitude-co-ordinates https://www.childs.be/articles/post/excel-how-to-calculate-distances-between-longitude-latitude-co-ordinates Here's a blast from excel past, it was actually one of the more interesting projects I worked on. We were designing food waste recycling plants for the food manufacture and retail industries. The task was to calculate the most efficient solution ofhow many recycling plants to build and where to build them based on the waste arising of each shop <p><strong><a href="https://www.childs.be/data/uploads/OS-Logo.jpg" rel="fb"><img alt="" src="https://www.childs.be/data/uploads/OS-Logo.jpg" style="width: 200px; height: 200px; float: right;" /></a>Here&#39;s a blast from excel past, it was actually one of the more interesting projects I worked on. We were designing food waste recycling plants for the food manufacture and retail industries. The task was to calculate the most efficient solution ofhow many recycling plants to build and where to build them based on the waste arising of each shop and factory vs the cost to transport between the sites.</strong></p> <p>The finished algorythm wasn&#39;t that complicated, and I ran it for one, two, three four and five plant solutions. One of the bits of information that the work was predicated on was the sitings of each shop/factory and although I had the postcode my presumption was that converting them to x and y co-ordinates would be easy. Well, to cut a long story short it wasn&#39;t - I quite quickly found a lookup list of postcodes to latitude and longitude and after that it would just be a simple bit of triganometry and pythag right? Wrong!</p> <p>Turns out converting lat/long to east/north is a complete PITA! Thankfully the guys at Ordnance Survey have the answer in their everything you need to know guide:</p> <p><a href="https://www.ordnancesurvey.co.uk/docs/support/guide-coordinate-systems-great-britain.pdf">A guide to coordinate calculations</a>&nbsp;(<a href="https://www.childs.be/data/uploads/guide-coordinate-systems-great-britain.pdf">mirror</a>)</p> <p>Did that clear it up for you? Me neither,, the formula is a whopper:</p> <p><a href="https://www.childs.be/data/uploads/long-lat-NE.jpg" rel="fb"><img alt="" src="https://www.childs.be/data/uploads/long-lat-NE.jpg" style="width: 300px; height: 400px;" /></a></p> <p>Fortunately they make our lives a little easier by providing an Excel spreadsheet showing us how to calculate it and a whole lot of other stuff, yeah!</p> <p><a href="https://www.ordnancesurvey.co.uk/docs/support/projection-and-transformation-calculations.xls">Coordinate calculation sheet(XLS)</a>&nbsp;(<a href="">mirror</a>)</p> <p>It&#39;s a little detailed so if you open it and head over to the [lat,long to E,N] tab you see the custom function helpfully spitting out the answer.</p> <pre>=Lat_Long_to_East(DecimalLat,DecimalLong,a,b,E0,F0,DecimalPHI0,DecimalLAM0) =Lat_Long_to_North(DecimalLat,DecimalLong,a,b,E0,N0,F0,DecimalPHI0,DecimalLAM0)</pre> <p>Fortunately it is not all that complicated, most of the arguments are constant so we are just left with:</p> <pre>=Lat_Long_to_East(DecimalLat,DecimalLong,6377563.396,6356256.909,400000,0.9996012717,49,-2) =Lat_Long_to_North(DecimalLat,DecimalLong,6377563.396,6356256.909,400000,-100000,0.9996012717,49,-2)</pre> <p>Simples, now all you need to do is copy the macro module over to your spreadsheet and you are good to go.</p> <p>&nbsp;</p> Excel ordnancesurvey,os,excellongitude,latitude,convert Using OR in SUMIF in Excel Wed, 25 Jan 2017 08:00:00 +0000 https://www.childs.be/articles/post/using-or-in-sumif-in-excel https://www.childs.be/articles/post/using-or-in-sumif-in-excel Things have moved on since the days of DSUM, we now have the likes of SUMIFS from Excel 2007 onwards. Can't even remember life before SUMIFS having never being a fan on DSUM. But with all things in life everything moves on, everything is never good enough and now SUMIFS's shortcomings are beginning to pop up. The other week the need came up for a <p><strong>Things have moved on since the days of <a href="https://support.office.com/en-us/article/DSUM-function-53181285-0C4B-4F5A-AAA3-529A322BE41B">DSUM</a>, we now have the likes of <a href="https://support.office.com/en-gb/article/SUMIFS-function-c9e748f5-7ea7-455d-9406-611cebce642b">SUMIFS</a> from Excel 2007 onwards. Can&#39;t even remember life before SUMIFS having never being a fan on DSUM. </strong></p> <p>But with all things in life everything moves on, everything is never good enough and now SUMIFS&#39;s shortcomings are beginning to pop up.</p> <p>The other week the need came up for a handy way to integrate OR logic into the SUMIFS, saves on some extra column calculations and makes us all look a bit cleverer. It is possible via an array formula however it does have its limitations. The biggy being that the OR variables have to be hard coded in - not so good.</p> <p>Any how, it is simple enough to code up, just put the OR parameters in curly brackets and surround the SUMIFS with a SUM and you are away:</p> <pre>= SUM ( SUMIFS ( $C$2:$C$16 , $B$2:$B$16 , {1,2,3,4} ) )</pre> <p>works with COUNTIFS also:</p> <pre>= SUM( COUNTIFS( $B$2:$B$16 , {1,2,3,4} ) )</pre> <p>&nbsp;</p> Excel excel,sumifs,or,dsum,countifs "You only know what you know how to google" Fri, 30 Dec 2016 15:30:00 +0000 https://www.childs.be/articles/post/you-only-know-what-you-know-how-to-google https://www.childs.be/articles/post/you-only-know-what-you-know-how-to-google "You only know what you know how to google" - Martin Childs, 2016 This post was supposed to be about how create a custom Excel VBA function, the origination of the idea was despite my lifelong career of tinkering with excel I'd never come across or had the requirement to have a function cycle through the cell you input as a range to perform a <blockquote><strong><big>&quot;You only know what you know <em>how </em>to google&quot;</big><br /> - Martin Childs, 2016</strong></blockquote> <p>This post was supposed to be about how create a custom Excel VBA function, the origination of the idea was despite my lifelong career of tinkering with excel I&#39;d never come across or had the requirement to have a function cycle through the cell you input as a range to perform a calculalation on them.</p> <p>Nice, just the sort of Excel work I like, I firstly gave it a bash myself - I usually am able to wing the answer using induction. [Induction, if you didn&#39;t know is the actual method Sherlock Holmes uses rather than the often misquoted deductive reasoning.] No luck winging it so I turned to every programmers best friend Google.</p> <p>There&#39;s pretty much nothing in the coding world that is invented or revolutionary these days, everything has been done before, anything new is just an incremental improvement and it is all documented on the internet. So it was off to google to what was what.</p> <p>In hindsight I don&#39;t know whether I was having a bad day or I had lost my mind but for the life of me I couldn&#39;t find the simple answer I was looking for - everything solution was so convoluted I couldn&#39;t believe it. In fact I battled with it for a time much in excess of what it would usually take me.</p> <p>I eventually found a solution which was acceptable - through trial and error more than anything. So a while later when I got round to writing the method up I thought I&#39;d give it another google as you know how the saying goes:</p> <blockquote>You only know what you know</blockquote> <p>Well, would you believe it, this time around google was almost straight in there with the <a href="http://www.excel-easy.com/vba/examples/user-defined-function.html">answer</a>, damn it. Reflecting on the above adage it occurred to me that it is no longer true and have come up with a more up to date phrase:</p> <blockquote><big>&quot;You only know what you know <em>how </em>to google&quot;</big><br /> - Martin Childs, 2016</blockquote> <p>Hopefully I&#39;m the first one to coin it, but it probably like every app idea I come up with - one search on Google Play and it&#39;s already been done 20 times over!</p> Excel martin,childs,quotation,quote Excel: convert Postcode in x,y grid co-ordinates Tue, 05 Jul 2016 08:00:00 +0100 https://www.childs.be/articles/post/excel-convert-postcode-in-xy-grid-co-ordinates https://www.childs.be/articles/post/excel-convert-postcode-in-xy-grid-co-ordinates This is a cracking blast from the past, I was digging through my old personal macro excel backups when I came across this beauty. It dates back to my recycling plant development days, I had to devise an algorithm to work out the most economical site placements for food waste recycling facilities for a given highly dispersion of waste arisings. The <p><strong><img alt="" src="https://www.childs.be/data/uploads/axes2.gif" style="width: 200px; height: 177px; float: right; margin:10px;" />This is a cracking blast from the past, I was digging through my old personal macro excel backups when I came across this beauty.</strong></p> <p>It dates back to my recycling plant development days, I had to devise an algorithm to work out the most economical site placements for food waste recycling facilities for a given highly dispersion of waste arisings.</p> <p>The data I had to work with was in the form of a list of postcode locations along with annual waste tonnages. I had originally intended to lookup the addresses against my longitude/latitude list however turns out the maths to convert long/lat into something usable in excel was rather complex.</p> <p>I&#39;ve since worked this long/lat conversion out and have been meaning to write it up into a blog post but it is frankly pretty boring even by my standards.</p> <h3>Screen scraper</h3> <p>So back then my next angle of attack was to use a screen scraper - a bit of code I could fire the postcode off into the interweb and get back the result I needed. I already knew the site I was going to leverage, Streetmap.co.uk, as I&#39;d been using it for a while for all things MTB as it was it was the only service at the time where you could view Ordnance Survey maps.</p> <h3>The code</h3> <p>Paste this code into your VBA Project:</p> <script src="https://gist.github.com/mc3k/44b00bb8194694f12e2cb894f6a62ba0.js"></script> <p>Then all you need to do is place you cursor in the cell next to the postcode you want to look up and run the macro.</p> <p>If you have a list of postcodes the code will happily rattle down the list for you.</p> <h3>Uses</h3> <p>But what use is it to me I hear you ask? Plenty, I wasn&#39;t expecting you to need a recycling plant location algorythm, it has lots of uses:</p> <ul> <li>with a bit of&nbsp;Pythagoras you can determine the distances between two locations</li> <li>You can use it to plot locations (on a graph)</li> <li>(well two, I&#39;m sue there must be more!)</li> </ul> Excel Excel,convert,Postcode,xy,grid,co-ordinates How to assign a shortcut key to the Explode Excel addin Mon, 27 Jun 2016 08:00:00 +0100 https://www.childs.be/articles/post/how-to-assign-a-shortcut-key-to-the-explode-excel-addin https://www.childs.be/articles/post/how-to-assign-a-shortcut-key-to-the-explode-excel-addin Sorry to bore you with yet another Explode addin post, but I think this is worth it on a couple of fronts. Assingning a shortcut key to the explode plug-in makes more awesome - being able to devle into those dependants even quicker. Also seeing as as my initial explode post is one of my most read posts, I know you'll all lap it up. There are two <p><strong>Sorry to bore you with yet another <a href="https://www.childs.be/blog/tag/explode">Explode addin post</a>, but I think this is worth it on a couple of fronts. Assingning a shortcut key to the explode plug-in makes more awesome - being able to devle into those dependants even quicker.</strong></p> <p>Also seeing as as my i<a href="https://www.childs.be/blog/post/explode-the-must-have-excel-add-in">nitial explode post</a> is one of my most read posts, I know you&#39;ll all lap it up.</p> <p>There are two ways of doing this, either to assign a shortcut in the ribbon macro window this is by far the easiest method, or to code it in VBA.</p> <h2>First Method</h2> <p>The trick here is that you need to know the name of the Sub which calls the main prog, however since the VBA project is locked for viewing you&#39;ll have to trust me in knowing what it is called.....</p> <p><a href="https://www.childs.be/data/uploads/explode-shortcut.jpg" id="fb"><img alt="" src="https://www.childs.be/data/uploads/explode-shortcut.jpg" style="width: 600px; height: 449px;" /></a></p> <p>First of all you have to enable the developer ribbon - <a href="https://msdn.microsoft.com/en-GB/library/bb608625.aspx">instructions here</a>.</p> <p>Then its just a matter of clicking the Developer tab, selecting the Macros button and type the following in the top box:</p> <pre>Explode.xla!ShowExplodeForm</pre> <p>If you spelled it correctly the options button should make itself available where you can then input your shortcut of choice. You&#39;ll need to try to avoid an already take key combo (so stick to Ctrl-Shift-something), my preference is Ctrl-Shift-X. To enter this just hold down shift and type X in the box then hit OK. You can then cancel the dialogue and merrily save a few seconds a day!</p> <h2>Second method</h2> <p>The next method is to insert some code into the ThisWorkbook object in the addin&#39;s VBA project, however since we&#39;ve already established it is locked - I have a workaround - we&#39;ll put it in our Personal Macro workbook.</p> <p>First off we&#39;ll have to enable the addins references to call from our code, from the menu bar go to Tools then References and check the VBA_Explode box.</p> <p>Then all we need to do is paste the following code in your personal macro book&#39;s ThisWorkbook object:</p> <pre>Option Explicit Private Sub Workbook_Open() Application.OnKey &quot;^+X&quot;, &quot;VBA_Explode.ShowExplodeForm&quot; End Sub</pre> <p>Hit save up at the top and reopen Excel and test it out - Ctrl-Shift-X should get you rockin&#39;.</p> Excel excel,shortcut,addin,developer,explode Create your own custom formatting shortcut in excel Sun, 19 Jun 2016 08:00:00 +0100 https://www.childs.be/articles/post/create-your-own-custom-formatting-shortcut-in-excel https://www.childs.be/articles/post/create-your-own-custom-formatting-shortcut-in-excel Like with most things in life, the longer you do something for the more you get set in your ways. Excel is no exception and if I'm a sucker for anything it's number formatting. Maybe it's the accountant in me, but I think negative numbers are easier to read and look far more stylish wiht a bracket around them. Then if you are going to use a <p><img alt="" src="https://www.childs.be/data/uploads/format-toggle.jpg" style="width: 282px; height: 69px; float: right;" />Like with most things in life, the longer you do something for the more you get set in your ways. Excel is no exception and if I&#39;m a sucker for anything it&#39;s number formatting.</p> <p>Maybe it&#39;s the accountant in me, but I think negative numbers are easier to read and look far more stylish wiht a bracket around them. Then if you are going to use a bracket you <em>must</em> sort the alignment out.</p> <p>Next is the zeros, it&#39;s gotta be just a dash, trust me. If you are looking at a model and you&#39;ve go a sheet full of zeros you need to know if they are really a zero or just a small enough number to be rounded as zero.</p> <p>Here&#39;s it in it&#39;s custom formating code along with the percentage style also:</p> <pre>#,##0_);(#,##0);-_) 0.00%_);(0.00%);-_)</pre> <p>All we need is the following bit of code hooked up to assigning a shortcut (in this case Ctrl-Shift-M), using the shortcut cycles through the formats, done!</p> <p>Paste this code into a macro module in you personal macro workbook:</p> <pre>Sub mcFormattoggle() &#39; &#39; MC_Format Macro &#39; numformat = Cells(Selection.Row, Selection.Column).NumberFormat Select Case numformat Case &quot;General&quot; Selection.NumberFormat = &quot;#,##0_);(#,##0);-_)&quot; Case &quot;#,##0_);(#,##0);-_)&quot; Selection.NumberFormat = &quot;0.00%_);(0.00%);-_)&quot; Case Else Selection.NumberFormat = &quot;General&quot; End Select End Sub</pre> <p>Then in the <span style="font-family:courier new,courier,monospace;">ThisWorkbook </span>object paste this code which will assign you shortcut. In this instance it is Ctrl-Shift-M</p> <pre>Option Explicit Private Sub Workbook_Open() Application.OnKey &quot;^+M&quot;, &quot;mcToggleFormat&quot; End Sub</pre> <p>Save then restart Excel and you are away!</p> Excel excel,shortcut,format,macro,toggle Explode Excel Addin - download Latest 2008 version Sat, 11 Jun 2016 20:00:00 +0100 https://www.childs.be/articles/post/explode-excel-addin-download-latest-2008-version https://www.childs.be/articles/post/explode-excel-addin-download-latest-2008-version After many months struggling with my favorite excel explode addin, I've finally discovered the solution to my issues. The problems started after I arrived at a new job - the computers were super locked down and they had Office 2010. I had problems installing the addin and even when it was working there was no 'Explode..' option on the right-click <p><strong><a href="https://www.childs.be/data/uploads/explode-version.jpg" id="fb"><img alt="" src="https://www.childs.be/data/uploads/explode-version.jpg" style="width: 194px; height: 238px; float: right;" /></a>After many months struggling with my favorite excel explode addin, I&#39;ve finally discovered the solution to my issues.</strong></p> <p>The problems started after I arrived at a new job - the computers were super locked down and they had Office 2010. I had problems installing the addin and even when it was working there was no &#39;Explode..&#39; option on the right-click context menu - my main way of accessing it. I also couldn&#39;t click outside the window when it was running, most inconvenient. I eventually got used to using the ribbon shortcut but then I ran into more trouble.</p> <p>I got myself a new laptop, this one was a vast improvement on the brick I had before - everything ran super quick, however it had one major issue - it had Office 2015 64bit installed. I could get the addin installed but it wouldn&#39;t run. I spend an age tweaking the security and trusted location settings to no avail.</p> <p>It was then I got thinking, I know that it had been discontinued some years ago but did I have the latest version installed, the quick answer was NO! My mistake - not following <a href="https://www.childs.be/blog/post/explode-the-must-have-excel-add-in">my own blog posting</a>, Checking against the version I had on my home PC I had downloaded it from a different website and had the 2002 edition not the &#39;latest&#39; 2008 version. Dumb-ass.</p> <p>So to sum up:</p> <div class="alert alert-success">Only download from the original <a href="http://xl-logic.com/excel/download/explode.zip">XL-Logic.com</a> website (the main website has been taken down but the download section still works.</div> <div class="alert alert-info">Or you can download from my <a href="https://www.childs.be/data/uploads/explode.zip">mirror</a>.</div> <div class="alert alert-danger">Don&#39;t download from the&nbsp;<a href="http://www.cfprojectfinance.co.uk/CFPFaddin.php">Clubfinance Project Finance</a> website - it&#39;s a really old version!</div> Excel explode,excel,addin,latest,version How to reset the default cell formatting in an Excel spreadsheet Wed, 30 Sep 2015 20:00:00 +0100 https://www.childs.be/articles/post/how-to-reset-the-default-cell-formatting-in-an-excel-spreadsheet https://www.childs.be/articles/post/how-to-reset-the-default-cell-formatting-in-an-excel-spreadsheet One of the more irritating things you can come across in someones elses spreadsheet (on the basis that I've never managed to reproduce it myself) is when somehow the default style has been changed to spit out a daft format of 00:00:00 for seemingly any number. This is especially apparant of you are a regular user of the clear formats function. It <p><a href="https://www.childs.be/data/uploads/defaultformat.jpg" id="fb"><img alt="" id="" src="https://www.childs.be/data/uploads/defaultformat.jpg" style="width: 172px; height: 116px; float: right; margin:10px;" /></a>One of the more irritating things you can come across in someones elses spreadsheet (on the basis that I&#39;ve never managed to reproduce it myself) is when somehow the default style has been changed to spit out a daft format of <code>00:00:00</code> for seemingly any number.</p> <p>This is especially apparant of you are a regular user of the clear formats function. It is a staple of mine in a few different circumstances, notably in clearing other peoples gash formatting &amp; when you want to quickly see more significant figures regarless of the current formatting you have.</p> <p>There are two ways to do this, you can put it in a macro or manually</p> <pre>Sub ResetNormalStyle() &nbsp;&nbsp;&nbsp; ActiveWorkbook.Styles(&quot;Normal&quot;).NumberFormat = &quot;General&quot; End Sub</pre> <p>or my favorite personal style</p> <pre>Sub ResetNormalStyleMC() &nbsp;&nbsp;&nbsp; ActiveWorkbook.Styles(&quot;Normal&quot;).NumberFormat = &quot;#,##0,_);(#,##0,);-_)&quot; End Sub</pre> <p>&nbsp;</p> Excel excel,format,style,vba,macro An enhanced name manager for Microsoft Excel Fri, 26 Jun 2015 08:00:00 +0100 https://www.childs.be/articles/post/an-enhanced-name-manager-for-microsoft-excel https://www.childs.be/articles/post/an-enhanced-name-manager-for-microsoft-excel Named ranges are one of those marmite things in Excel, either you use them or you don't. I sit between the two camps and my utilisation depends on two things: Firstly who the end user will be and whether they'll need to interact with them. The other is a timesaving thing - their use will depend on if it will save me time over the long run. My <p><strong><a href="https://www.childs.be/data/uploads/name-manager.jpg" id="fb"><img alt="" src="https://www.childs.be/data/uploads/name-manager.jpg" style="width: 343px; height: 300px; float: right; margin: 10px;" /></a>Named ranges are one of those marmite things in Excel, either you use them or you don&#39;t. I sit between the two camps and my utilisation depends on two things:</strong></p> <p>Firstly who the end user will be and whether they&#39;ll need to interact with them.</p> <p>The other is a timesaving thing - their use will depend on if it will save me time over the long run.</p> <p>My actual use of named ranges was pretty minimal as Excel&#39;s built in Name Manager is pretty basic being just a list.</p> <p>However I after coming across this <a href="http://www.jkp-ads.com/officemarketplacenm-en.asp">enhanced add-in</a> has driven me to use them more and more.</p> <p>I&#39;ll give you the blurb:</p> <div class="well">If you are in need of a utility to manage defined names in your Excel models, this one is a must-have. List all names in your active workbook. Filter them using 13 filters, e.g. &quot;With external references&quot;, &quot;With errors&quot;, Hidden, Visible. Show just names that contain a substring. Show just names unused in worksheet cells. Edit them in a simple dialog or make a list, edit the list and update all names in one go. Delete, hide, unhide selected names with a single mouse click.</div> <p>I&#39;m not sure if there is much I can add, that is a pretty comprehensive list of its functions. I&#39;d encourage everybody to give it a go. It is definately an invaluable resource for me as there are a load of spreadheets I come across that have been infected with hundreds of broken and external named ranges that are of no use to the function of the spreadsheet that can be banished quickly.</p> <h4>Install instructions</h4> <p>Download the zip from <a href="http://www.jkp-ads.com/officemarketplacenm-en.asp">here</a>. Unpack the files in the zip file to a folder of your liking and open the file called &quot;Setup Name Manager.xls&quot;. Press the button in that file to install. I did have trouble with the latest version though, had to go back to an older version I had lying about.</p> Excel name,manager,excel,addin,formula Extract a Surname from a string in Excel Wed, 10 Jun 2015 08:00:00 +0100 https://www.childs.be/articles/post/extract-a-surname-from-a-string-in-excel https://www.childs.be/articles/post/extract-a-surname-from-a-string-in-excel There comes a point in every Excel users workflow that they've got to work with a list of names. Usually the data you get is in the wrong format, or you have to compare two dataset of different formats. This can be frustrating but here is a quick guide of how to manipulate them. This tutorial is based around extracting the surname / family name <p><strong><a href="https://www.childs.be/data/uploads/extract-surname.png" id="fb"><img alt="" src="https://www.childs.be/data/uploads/extract-surname.png" style="width: 316px; height: 97px; float: right;" /></a>There comes a point in every Excel users workflow that they&#39;ve got to work with a list of names. Usually the data you get is in the wrong format, or you have to compare two dataset of different formats. This can be frustrating but here is a quick guide of how to manipulate them.</strong></p> <p>This tutorial is based around extracting the surname / family name from a variety of different formats, if you need to get to the title or firstname then it should be easily enough to adapt the workarounds.</p> <h3>Surname, Forename</h3> <p>Possibly the best format to get the data in, it is quick and easy to extract the surname, like everything in excel all you have to do is break the task into logical steps. Lets go with this example:</p> <blockquote>Fish, Phil the</blockquote> <p>Breaking it down, the portion of the name we want to take are all the letters before the comma. Using the <code>FIND</code> function and assuming the string is in cell A1 we&#39;d use this formula:</p> <pre>=FIND(&quot;,&quot;,A1,1)-1</pre> <p>This results in the expected answer of 4. All we need to do next is use the <code>LEFT</code> formula to extract the letters:</p> <pre>=LEFT(A1,4)</pre> <p>We can then nest these formulas into one compact equation:</p> <pre>=LEFT(A1,FIND(&quot;,&quot;,A1,1)-1)</pre> <p>Et voila</p> <blockquote>Fish</blockquote> <h3>Title Forename Initial Surname</h3> <p>It wouldn&#39;t be so bad to extract the Surname from a Forename Surname configuration, you just repeat the above steps but instead look for a space and use the RIGHT function along with <code>LEN</code> - which tells you how many characters are in the string so you can extract the space to last letter. E.g. for</p> <blockquote>Phil Fish</blockquote> <pre>=RIGHT(A1,LEN(A1)-FIND(&quot; &quot;,A1))</pre> <p>Again giving you</p> <blockquote>Fish</blockquote> <p>the trouble is that the data rarely comes through like this. There are several permitations which will come through including middle name/no middle name/multiple middle names and title:</p> <blockquote>Phil Fish<br /> Phil the Fish<br /> Lord Phil Fish<br /> Phil Overloard of All Fish</blockquote> <p>Back to our human logic, all we really have to do here is take the letters after the last space, unfortunately this is trickier than it sounds!</p> <p>To accomplish our task we have to break this down into futher steps, first off:</p> <p>&nbsp;</p> <h4>Count the number of spaces</h4> <p>Counting how many occurances a string has can be calculated by counting the total length of the string minus the length of the string without the text you are trying to find. Pretty cunning really, you&#39;ll have needed a bit of out of the box thinking for that one. <a href="http://support.microsoft.com/kb/187667">Here&#39;s</a> the formula to use:</p> <pre>=SUM(LEN(&lt;range&gt;)-LEN(SUBSTITUTE(&lt;range&gt;,&quot;text&quot;,&quot;&quot;)))/LEN(&quot;text&quot;)</pre> <p>or in the context of our example:</p> <blockquote>Phil the Fish</blockquote> <p>this formula:</p> <pre>=SUM(LEN(A1)-LEN(SUBSTITUTE(A1,&quot; &quot;,&quot;&quot;)))/LEN(&quot; &quot;)</pre> <p>&nbsp;</p> <p>will yield the answer of 2.</p> <p>&nbsp;</p> <h4>Find the last occurance</h4> <p>Now we have found how many times the space appears we have to locate the last occurance, we do this by replacing the last space with something unique which we know won&#39;t appear for this we&#39;ll use a special system charachter Null and call it using the <a href="http://www.techonthenet.com/excel/formulas/char.php">CHAR</a> function which retreives is using its <a href="http://www.asciitable.com/">ASCII</a> code:</p> <pre>CHAR(1)</pre> <p>So as a <a href="http://excel.tips.net/T003324_Finding_the_Nth_Occurrence_of_a_Character.html">formula</a> we&#39;ll substitute the space in the text string and find it:</p> <pre>=FIND(CHAR(1),SUBSTITUTE(A1,&quot; &quot;,CHAR(1),2))</pre> <p>This give us the position of 9,</p> <p>&nbsp;</p> <h4>Extract the surname</h4> <p>Next all we have to do is proceed to grab the last 9 letters of the string as described earlier and we are away:</p> <pre>=RIGHT(A1,9)</pre> <p>&nbsp;</p> <h4>Condense into one formula</h4> <p>Finally once we&#39;ve figured out all the steps we can bung all the code into one formula:</p> <pre>=RIGHT(A1,LEN(A1)-FIND(CHAR(1),SUBSTITUTE(A1,&quot; &quot;,CHAR(1),SUM(LEN(A1)-LEN(SUBSTITUTE(A1,&quot; &quot;,&quot;&quot;)))/LEN(&quot; &quot;))))</pre> <p>And we are away. I told you it wasn&#39;t as easy as you first imagined!</p> Excel excel,char,substitute,len,right,left,surname,extract,find Creating hyperlinks in Excel that are relative & actually work Wed, 25 Feb 2015 08:00:00 +0000 https://www.childs.be/articles/post/creating-relative-hyperlinks-in-excel https://www.childs.be/articles/post/creating-relative-hyperlinks-in-excel If you've ever tried to create a hyperlinks in excel you'll know what a pain they are. The hyperlink tool on the Insert ribbon is quite useful, but it is a pain to create a lot of them. The big problem however is that they are not relative - if you add more columns or rows suddenly your hyperlink is pointing to the wrong place. You could use the <p><img alt="" src="https://www.childs.be/data/uploads/hyperlink.png" style="width: 200px; height: 133px; float: right;" /></p> <h4>If you&#39;ve ever tried to create a hyperlinks in excel you&#39;ll know what a pain they are.</h4> <p>The <a href="https://support.office.microsoft.com/en-gb/article/Create-select-edit-or-delete-a-hyperlink-472fce40-c5f0-427e-90d4-12c0366bc06f?CorrelationId=c9dfaf30-2b91-4d7c-bc75-fd40a0bf6462&amp;ui=en-US&amp;rs=en-GB&amp;ad=GB#__toc289683023">hyperlink tool</a> on the Insert ribbon is quite useful, but it is a pain to create a lot of them. The big problem however is that they are not relative - if you add more columns or rows suddenly your hyperlink is pointing to the wrong place.</p> <p>You could use the <a href="https://support.office.microsoft.com/en-gb/article/Create-select-edit-or-delete-a-hyperlink-472fce40-c5f0-427e-90d4-12c0366bc06f?CorrelationId=c9dfaf30-2b91-4d7c-bc75-fd40a0bf6462&amp;ui=en-US&amp;rs=en-GB&amp;ad=GB#__toc289683024">custom hyperlink formula</a>, this will let you create a lot of entries more quickly, however it is still not relative and has more issues.</p> <pre>=HYPERLINK(&quot;[Budget]June!E56&quot;, E56)</pre> <p>This is because the address is entered as text so is not a cell address. Also we now have the problem that the spreadsheet name is now also hardcoded so if you change the spreadsheet name you&#39;ve now scuppered youself.</p> <p>Pretty crappy really seeing as this is Micro$ofts own tutorial! So in the next evolution of its usuage would be to add the filename in dynamically using the following function:</p> <pre>=CELL(&quot;filename&quot;,C9)</pre> <p>However to be able to use it in the formula we need to extract just the filename so we have to use:</p> <pre>=LEFT(CELL(&quot;filename&quot;,C10),FIND(&quot;]&quot;,CELL(&quot;filename&quot;,C10)))</pre> <p>This is also very clumsy as we are still harcoded - not relative - and trying to dig ourselves out of the predicament we are going to make it even more complicated.</p> <p><strong>The solution</strong></p> <p>What we need is a subtle tweak, this is the <a href="http://windowssecrets.com/forums/showthread.php/44966-Hyperlinks-not-relative-%28EXCEL-97-2000%29#post240551">answer</a>:</p> <pre>=HYPERLINK(&quot;#&quot;&amp;CELL(&quot;address&quot;,M235),&quot;Actuals Summary&quot;)</pre> <p>Nice, simple and hitting all the buttons.</p> Excel excel,tips,hyperlink Excel function to list worksheet names Tue, 02 Sep 2014 16:08:57 +0100 https://www.childs.be/articles/post/excel-function-to-list-worksheet-names https://www.childs.be/articles/post/excel-function-to-list-worksheet-names Ever wanted to list all the tabs in a workbook or reference a specific sheet by its placing, look no further..... This funky little custom VBA function can be used simply as a contents sheet, This is a particularily useful tool tool when used with the indirect function, it will allow you to soft-link to any cell within your worksheet. There are a <p><strong><a href="https://www.childs.be/data/uploads/worksheetname.png" id="fb"><img alt="" src="https://www.childs.be/data/uploads/worksheetname.png" style="width: 311px; height: 202px; float: right; padding: 10px;" /></a>Ever wanted to list all the tabs in a workbook or reference a specific sheet by its placing, look no further.....</strong></p> <p>This funky little custom VBA function can be used simply as a contents sheet, This is a particularily useful tool tool when used with the indirect function, it will allow you to soft-link to any cell within your worksheet.</p> <p>There are a few things you should note though, it sometimes won&#39;t update after a sheet move/copy/delete/rename so a good old calc all - <code>Ctrl-Alt-F9</code> won&#39;t go amiss.</p> <pre>Function WorksheetName(SheetNo As Integer) &nbsp;&nbsp;&nbsp; &#39;Function to return worksheet name for its given number order &nbsp;&nbsp;&nbsp; &#39;Copyright Marty Childs 2008 &nbsp;&nbsp;&nbsp; &#39;Usage =WorksheetName(1) will return &quot;Sheet1&quot; in a blank workbook &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WorksheetName = ThisWorkbook.Sheets(SheetNo).Name End Function</pre> <p>Follow these instructions to create the macro for Excel <a href="http://office.microsoft.com/en-gb/excel-help/create-a-macro-HP005204711.aspx">2003</a> or <a href="http://office.microsoft.com/en-gb/excel-help/create-or-delete-a-macro-HP010014111.aspx#BMcreatemacrovba">2007</a>. Also the function needs to be saved into workbook itself so it is available to everyone and for 2007 users and above dont forget to save the file as a macro-enabled workbook.</p> Excel excel,worksheet,name Explode - the must have excel add in Mon, 11 Aug 2014 08:00:00 +0100 https://www.childs.be/articles/post/explode-the-must-have-excel-add-in https://www.childs.be/articles/post/explode-the-must-have-excel-add-in Excel's built in formula auditing tools is and always has been rubbish, sure you may have got used to how they work and feel quite competent/happy with it - but the Explode excel addin will blow your mind! If you work with excel a lot and you don't use the add in Explode you're in one of two camps: not a power user, or both amazed at how you've <p><strong><a href="https://www.childs.be/data/uploads/explode.png" id="fb"><img alt="" src="https://www.childs.be/data/uploads/explode.png" style="width: 340px; height: 219px; float: right; padding: 10px;" /></a>Excel&#39;s built in formula auditing tools is and always has been rubbish, sure you may have got used to how they work and feel quite competent/happy with it - but the Explode excel addin will blow your mind!</strong></p> <p>If you work with excel a lot and you don&#39;t use the add in Explode you&#39;re in one of two camps:</p> <ul> <li>not a power user, or</li> <li>both amazed at how you&#39;ve gone without it thus far in life; and super annoyed that it&#39;s taken this long to find it!</li> </ul> <p>Explode is pretty old now (but as useful as ever) and the great peops over at XL-Logic.com who authored it have long since taken their website down, but you can still access it from their download page from <a href="http://xl-logic.com/excel/download/explode.zip">here</a>, (my <a href="https://www.childs.be/data/uploads/explode.zip">mirror</a>, <del>another <a href="http://www.cfprojectfinance.co.uk/CFPFaddin.php">mirror</a></del>).</p> <p><strong><em>Update 9-Jun-2016:&nbsp;</em></strong><em>&nbsp;<a href="https://www.childs.be/blog/post/explode-excel-addin-download-latest-2008-version">see my blog post</a>, don&#39;t download the addin from google&#39;s first hit of Clubfinance Project Finance as is a really old version.</em></p> <p><strong>To install</strong>:<br /> Extract <code>explode.xla</code> from the zip to any folder, then this (for Excel 2007) go to Excel Options, Add-Ins, then &#39;Manage: Excel Add-Ins&#39;, &#39;Go...&#39;. Broswe to the file you just extracted and you are away.</p> <p><strong>To use</strong>:<br /> Just right click a cell containing a formula and select &#39;Explode...&#39; and you are away. You can then trace both the pecedents and dependants with ease.</p> <div class="well">A powerful, intuitive, easy to use, and FREE formula auditing tool. Designed by a professional financial modeller to be used by experts and newbs alike. Once you start using it, you&#39;ll wonder how you ever managed without it. Imagine using the audit arrow feature on a formula and then tracing each precedent or dependent to find out what the value is and then finally returning back to that origin cell. Imagine if you could automate that process and display all that information instantly in a well organized interactive format. Now that would be a great formula auditing tool! One day I stopped wishing for it and just built it. Now you can have it too.</div> <p>Stay tuned for some more excel goodness, I&#39;ve got a blog post about another super usefull util, <a href="https://www.childs.be/blog/post/name-manager-another-great-excel-add-in">Name Manager</a>, coming up.</p> Excel excel,addin,formula,audit,explode Make a cell look like a button in Excel Tue, 22 Jul 2014 08:00:00 +0100 https://www.childs.be/articles/post/make-a-cell-look-like-a-button-in-excel https://www.childs.be/articles/post/make-a-cell-look-like-a-button-in-excel There a sometimes in excel where you want to create a button but you don't want to introduce VB into your workbook (there are many reasons not to) - heres how. I'm a great advocate of not using VBA / macros when you don't have to - they are not widely understood, easy to break when you alter the workbook and introduce a plethora of security <p><a href="https://www.childs.be/data/uploads/excel-button.png" id="fb"><img alt="Unhide all sheets" src="https://www.childs.be/data/uploads/excel-button.png" style="width: 221px; height: 130px; margin: 10px; float: left;" /></a><strong>There a sometimes in excel where you want to create a button but you don&#39;t want to introduce VB into your workbook (there are many reasons not to) - heres how.</strong></p> <p>I&#39;m a great advocate of not using VBA / macros when you don&#39;t have to - they are not widely understood, easy to break when you alter the workbook and introduce a plethora of security issues. And with the newer versions of excel they can prove troublsome with users not enabling macros and saving the workbook in a non macro-enabled format (i.e. .xlsm).</p> <p><a href="https://www.childs.be/data/uploads/borders.png" id="fb"><img alt="" src="https://www.childs.be/data/uploads/borders.png" style="width: 270px; height: 236px; float: right;" /></a></p> <p>Here is how to:</p> <ul> <li>first pick the main coulour of the button and fill the cell. To make your first attempt simply select a colour in the middle of a shade range;</li> <li>the open up the &#39;Format Cells&#39; dialog, the easiest way; to do this is right-clicking the cell where you will see it in the context menu;</li> <li>switch to the &#39;Border&#39; tab;</li> <li>in the Color dropdown box pick the shade lighter than your main fill colour;</li> <li>select the middle weight solid line from the style selection;</li> <li>in the border box click the top line and the left line;</li> <li>repeat the previous three steps with a darker shade and the bottom and left lines;</li> <li>click OK to see your creation;</li> </ul> <p>You may want to go back at this point to tweak your colours and/or line thickness to get the best results.</p> <p>This trick is best used with a hyperlink to open another document/webpage; link to a specified&nbsp; place within the workbook or even to lanch a script or other program. See my blog post about <a href="https://www.childs.be/blog/post/creating-relative-hyperlinks-in-excel">how to properly set up a hyperlink</a>.</p> <p>&nbsp;</p> Excel excel,button,hyperlink,macro Excel - Add comment directly into formulas Sat, 18 Apr 2009 11:23:00 +0100 https://www.childs.be/articles/post/excel-add-comment-directly-into-formulas https://www.childs.be/articles/post/excel-add-comment-directly-into-formulas Ever known anybody who hardcodes numbers into formulas? Does it drives you mad because they leave no explanation of why? Well this may be the function you should tell them about. You can use the N() function to add a comment inline with a formula. What it actually is mean't for is to try to convert a string into a number, but if you just put words <p><a href="https://www.childs.be/data/uploads/formula-comment.png" id="fb"><img alt="" src="https://www.childs.be/data/uploads/formula-comment.png" style="width: 227px; height: 114px; float: left; margin:10px;" /></a><strong>Ever known anybody who hardcodes numbers into formulas? Does it drives you mad because they leave no explanation of why? Well this may be the function you should tell them about.</strong></p> <p>You can use the <code>N()</code> function to add a comment inline with a formula. What it actually is mean&#39;t for is to try to convert a string into a number, but if you just put words in there the output of the formula is zero.</p> <p>Although come to think of it, you&#39;ve probably already told this person to explain their actions and they haven&#39;t listened to you so they probably won&#39;t now! Best to keep it to yourself for explaining stuff you don&#39;t want to use a comment for.</p> <p>See example below:</p> <pre>=A1+A2*0.85+N(&quot;your comment&quot;)</pre> Excel excel,comment,formula Excel - Calculating Pi Fri, 31 Oct 2008 17:46:00 +0000 https://www.childs.be/articles/post/excel-calculating-pi https://www.childs.be/articles/post/excel-calculating-pi If you are finding the inbuilt excel function for =Pi() is just a bit too dull, there a handy function to calculate Pi on the fly. You may want to use it sparingly though, too many times in one spreadsheet or to many decimal places and you'll grind to a halt as it is a bit processor hungry!: Function myPi(places) 'Places is the number of decimal <p><a href="https://www.childs.be/data/uploads/pi-symbol-md.png" id="fb"><img alt="Calculating pi" src="https://www.childs.be/data/uploads/pi-symbol-md.png" style="width: 60px; height: 59px; float: right; padding-left: 10px; padding-bottom: 10px;" /></a><strong>If you are finding the inbuilt excel function for <code>=Pi()</code> is just a bit too dull, there a handy function to calculate Pi on the fly.</strong></p> <p>You may want to use it sparingly though, too many times in one spreadsheet or to many decimal places and you&#39;ll grind to a halt as it is a bit processor hungry!:</p> <pre>Function myPi(places) &#39;Places is the number of decimal place accuracy you want x = 1 a = 4 b = -1 Do While Round(c, places) &amp;lt;&amp;gt; Round(a, places) c = a a = a + (4 / (x * 2 + 1)) * b b = b * -1 x = x + 1 Loop myPi = Round(a, places) End Function</pre> Excel excel,pi,formula Excel - Unhide all sheets Fri, 31 Oct 2008 11:02:00 +0000 https://www.childs.be/articles/post/excel-unhide-all-sheets https://www.childs.be/articles/post/excel-unhide-all-sheets This little sub quickly unhides all hidden sheets (including xlVeryHidden). I use it frequently as people tend to hide worksheets which are no longer needed rather than just delete them, also especially useful when trying to dissect other peoples creations. It also has some sneaky uses, I regularily come across people who like to protect the <p><a href="https://www.childs.be/data/uploads/unhide-sheets.png" id="fb"><img alt="Unhide all sheets" src="https://www.childs.be/data/uploads/unhide-sheets.png" style="width: 200px; height: 85px; margin: 10px; float: left;" /></a><strong>This little sub quickly unhides all hidden sheets (including xlVeryHidden). I use it frequently as people tend to hide worksheets which are no longer needed rather than just delete them, also especially useful when trying to dissect other peoples creations.</strong></p> <p>It also has some sneaky uses, I regularily come across people who like to protect the content of their macros and spreadsheet from prying eyes. Usually they make the fatal mistake of making the visibility of tabs they don&#39;t want people to see as <code>xlSheetVeryHidden</code>, then password protect the macros. What a mistake indeed, the function below gets straight around this:</p> <pre>Sub unhide_all_sheets() Dim wksht As Worksheet For Each wksht In ActiveWorkbook.Worksheets Sheets(wksht.Name).Visible = True Next wksht End Sub</pre> <p>I&#39;m not even using an exploit for this, its just plain old user error - whist password protecting the macros blocks UI access to the sheet properties in Visual Basic, it does not lock access to the field as a command.</p> <p>To properly protect the required tabs the user must <code>Protect Workbook</code>. Not that even this will stop someone who really wants to gain access ;-)</p> Excel excel,unhide,macro