Spy Journal 3.0 - MATCH
https://www.spyjournal.biz/taxonomy/term/118/0
enRound up of Excel Tips and Hints
https://www.spyjournal.biz/round-excel-tips-and-hints
<p>As Office 2010 becomes more prevalent in the workplace (most of our clients either have or will be soon updating to it) so the use of the ribbon has become more natural and intuitive for people. It is certainly much more intuitive than the old menu driven interface.</p>
<p><a href="http://www.spyjournal.biz/files/rh2-150x150.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="rh2-150x150" border="0" alt="rh2-150x150" align="right" src="http://www.spyjournal.biz/files/rh2-150x150_thumb.png" width="154" height="154" /></a>Play a fun game called <a href="http://blogs.office.com/b/microsoft-excel/archive/2011/06/07/build-excel-smarts-with-ribbon-hero-2.aspx">Ribbon Hero 2</a> that allows you to learn the fastest and best ways to do various common tasks in the various Office Apps. My kids are using this to learn the interface and some of these common tasks. I have even learnt some things in the 5 minutes I have spent playing it so far! <a href="http://www.ribbonhero.com/">Download Ribbon Hero 2</a>.</p>
<p><a href="http://blogs.office.com/b/microsoft-excel/archive/2011/05/10/take-the-first-step-in-growing-your-excel-skills.aspx">Take the first step in growing your Excel Skills</a>. Microsoft have created a series of learning videos that assist new users to Excel to grow their skills</p>
<p><a href="http://blogs.office.com/b/microsoft-excel/archive/2011/06/01/learn-how-to-create-your-own-excel-macros-in-this-free-training-course.aspx">Learn how to create your own Excel Macros with a free training course</a>. Ideal for the entry level person who wants to explore macro writing for the first time. Note this doesn't create efficient code, but its a start to understanding how the VBA code interacts with Excel.</p>
<p><a href="http://blogs.office.com/b/microsoft-excel/archive/2011/05/24/getting-started-with-powerpivot-for-excel.aspx">PowerPivot for Excel</a> - if you have looked or used <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e081c894-e4ab-42df-8c87-4b99c1f3c49b&displaylang=en">PowerPivot</a> (See my <a href="http://www.spyjournal.biz/node/1197">review of Power Pivot</a>) than this page has some good links for additional resources.</p>
<!--break--><!--break--><h3>Ribbon</h3>
<p>The ribbon is also extensible via code and can be added to or modified as required for specific applications and requirements.</p>
<p><a href="http://www.dailydoseofexcel.com/archives/2011/06/07/enable-or-disable-custom-ribbon-buttons-in-excel-2007-2010/">Enable or Disable Custom Ribbon Buttons in Excel 2007-2010</a>. Links from Ron to his site where he shows how to work with the ribbon in VBA.</p>
<p><a href="http://blogs.office.com/b/microsoft-excel/archive/2011/05/19/avoid-losing-the-state-of-the-global-iribbonui-ribbon-object.aspx">Avoid losing the state of the global IRibbonUI ribbon object</a>. Frederique explains the problem and points to how to solve it.</p>
<h3>Performance</h3>
<p>Charles Williams has some great performance related code tips. </p>
<p><a href="http://fastexcel.wordpress.com/2011/05/25/writing-efficient-vba-udfs-part-1/">Write efficient VBA UDFs using Excel Functions inside a UDF - Part 1</a></p>
<p><a href="http://fastexcel.wordpress.com/2011/06/06/writing-efficient-vba-udfs-part-2/">Write efficient VBA UDFs using Excel Functions inside a UDF - Part 2</a></p>
<h3>Lookups</h3>
<p>Charley Kyd talks about <a href="http://exceluser.com/blog/727/excels-fastest-lookup-methods-the-tested-results.html">Excels fastest Lookup Methods</a> the INDEX MATCH dual formula approach is much faster than the single VLOOKUP formula. I have been using this method for some time now to significantly improve calculation times in large workbooks and lookups on data sets.</p>
<p>Daniel Ferry writes on Excel Hero a very good <a href="http://www.excelhero.com/blog/2011/03/the-imposing-index.html">reference guide to using the INDEX and INDEX MATCH functions</a> in numerous scenarios including dynamic range names (in place of volatile functions like OFFSET).</p>
<p>Tushar writes about how to perform <a href="http://www.tushar-mehta.com/publish_train/xl_vba_cases/0106%202D%20lookup.shtml">Two Dimensional Lookups</a>.</p>
<p>Finally Mikkel Sciegienny explains in depth <a href="http://spreadsheeto.com/index-match/" target="blank">how to use INDEX MATCH in this user friendly article</a>.</p>
https://www.spyjournal.biz/round-excel-tips-and-hints#commentsExcelINDEXMATCHOfficepivot tableRibbonVBAVLOOKUPhttps://www.spyjournal.biz/crss/node/1249Wed, 08 Jun 2011 20:10:14 +0000jethro1249 at https://www.spyjournal.bizExcel Function of the week - Using MATCH with VLOOKUP
https://www.spyjournal.biz/excel-function-week-using-match-vlookup
<p>When I wrote the <a href="/node/992">how to use VLOOKUP and HLOOKUP article</a> a few weeks ago I hinted at writing how to use the COLUMN, ROW, MATCH, INDEX and OFFSET functions to enhance the use of the VLOOKUP and HLOOKUP functions. Today we will look at the use of MATCH.</p>
<p><a href="http://www.spyjournal.biz/files/MagnifyingGlass.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="Magnifying Glass" border="0" alt="Magnifying Glass" align="right" src="http://www.spyjournal.biz/files/MagnifyingGlass_thumb.jpg" width="205" height="260" /></a> First of all here is a common scenario.</p>
<p>You create a table of say 4 columns, and then in another sheet you create a VLOOKUP function that returns results from the 4th column. EG <font color="#800000">=VLOOKUP(lookup_value,table_range,4,FALSE)</font> where the 4 relates to the 4th column. This works great until one day you (or your colleagues) delete the 3rd column in the table, or insert another column in the middle of the table. Now your VLOOKUP fails as the 4th column either doesn’t exist, or is now actually the 5th column. In this case the VLOOKUP formula you created is just not flexible enough to handle the changes.</p>
<p>The following explanation builds on the <a href="http://www.spyjournal.biz/exceltips/2004/10/dynamic-range-names.html">dynamic range name process</a> defined in my article written back in 2004. You will need to create a dynamic range name (in this example called table_header) that works on the header row of the table you are performing the VLOOKUP on.</p>
<p>In Excel 2007 Use the Name Manager from the Formula tab. In Excel 2003 and earlier use Edit Insert Name Define. In both versions CTRL F3 is the keyboard short cut.</p>
<!--break--><!--break--><p>Here is my sample table of data in Sheet1.</p>
<p><a href="http://www.spyjournal.biz/files/image_88.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_90.png" width="494" height="196" /></a> </p>
<p>Create a new range name and in the reference enter the OFFSET formula for a row. (assuming table is built from column A out and there is no other data in the sheet)</p>
<p><font color="#800000">=OFFSET(Sheet1!$A$1,0,0,1,COUNTA(Sheet1!$1:$1))</font></p>
<p><a href="http://www.spyjournal.biz/files/image_89.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_91.png" width="494" height="310" /></a> </p>
<p>On another sheet  I have a VLOOKUP formula designed to return the pay rate of a selected employee from a drop down list.</p>
<p>Originally it was like the picture here with this formula <font color="#800000">=VLOOKUP(A2,Sheet1!A:D,4,FALSE)</font></p>
<p><a href="http://www.spyjournal.biz/files/image_90.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_92.png" width="494" height="126" /></a> </p>
<p>Now in the VLOOKUP formula replace the column no (E.G. 4) with this MATCH formula <font color="#800000">MATCH(Sheet1!$D$1,table_header,0)</font> so the total formula now reads like this <font color="#800000">=VLOOKUP(A2,Sheet1!A:D,MATCH(Sheet1!$D$1,table_header,0),FALSE)</font></p>
<p>What this does is tell the formula to use the value in the header row in the column you want and return its position in the table_header range. Even if you go and change the name of that column to something else it will still work. Inserting a column in the middle of the table, or deleting a column from the table will not stop the VLOOKUP function from performing correctly.</p>
<p> </p>
<p>Finally, here is the Excel function layout and help for the MATCH function. Note the Match type argument can be –1, 0 or 1. Read the details below as to when you should use these values.</p>
<p><a href="http://www.spyjournal.biz/files/image_91.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_93.png" width="494" height="247" /></a></p>
<p>The <b>MATCH</b> function searches for a specified item in a range of cells, and then returns the relative position of that item in the range. For example, if the range A1:A3 contains the values 5, 25, and 38, then the formula</p>
<p><b>=MATCH(25,A1:A3,0)</b></p>
<p>returns the number 2, because 25 is the second item in the range.</p>
<p>Use <b>MATCH</b> instead of one of the <b>LOOKUP</b> functions when you need the position of an item in a range instead of the item itself. For example, you might use the <b>MATCH</b> function to provide a value for the <b><i>row_num</i></b> argument of the <b>INDEX</b> function.</p>
<h4>Syntax</h4>
<pre>MATCH(lookup_value, lookup_array, [match_type])</pre><p>The <b>MATCH</b> function syntax has the following arguments:</p>
<ul>
<li><b>lookup_value</b>  Required. The value that you want to match in <b><i>lookup_array</i></b>. For example, when you look up someone's number in a telephone book, you are using the person's name as the lookup value, but the telephone number is the value you want.
<p>The <b><i>lookup_value</i></b> argument can be a value (number, text, or logical value) or a cell reference to a number, text, or logical value.</p>
</li>
<li><b>lookup_array</b>  Required. The range of cells being searched. </li>
<li><b>match_type</b>  Optional. The number -1, 0, or 1. The <b><i>match_type</i></b> argument specifies how Excel matches <b><i>lookup_value</i></b> with values in <b><i>lookup_array</i></b>. The default value for this argument is 1.
<p>The following table describes how the function finds values based on the setting of the <b><i>match_type</i></b> argument. </p>
<p>Match_type Behavior</p>
<p>1 or omitted - <b>MATCH</b> finds the largest value that is less than or equal to <b><i>lookup_value</i></b>. The values in the <b><i>lookup_array</i></b> argument must be placed in ascending order, for example: ...-2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE.</p>
<p>0 - <b>MATCH</b> finds the first value that is exactly equal to <b><i>lookup_value</i></b>. The values in the <b><i>lookup_array</i></b> argument can be in any order.</p>
<p>-1 - <b>MATCH</b> finds the smallest value that is greater than or equal to<b><i> lookup_value</i></b>. The values in the <b><i>lookup_array</i></b> argument must be placed in descending order, for example: TRUE, FALSE, Z-A, ...2, 1, 0, -1, -2, ..., and so on.</p>
</li>
</ul>
https://www.spyjournal.biz/excel-function-week-using-match-vlookup#commentsMATCHOFFSETVLOOKUPhttps://www.spyjournal.biz/crss/node/1041Thu, 12 Feb 2009 23:44:05 +0000jethro1041 at https://www.spyjournal.bizDeveloping in Excel 2007
https://www.spyjournal.biz/developing-excel-2007
<p>I much prefer working in Excel 2007 to Excel 2003. Despite the issues with <a href="/exceltips/2007/04/excel-2007-and-backward-compatibility.html">backward compatibility</a>, there are a lot of advantages and benefits to using the new version.</p>
<p>Some little things that have been changed are</p>
<p>The previous limit on nested brackets in formulas from 7 has been increased to 64. I used this today</p>
<p>The number of columns and rows has increased. I used this today.</p>
<p>I had to develop a file for a client that involved a complex work roster arrangement to calculate days off in repeating 2, 3 or 4 week cycles for the next 20 years.</p>
<p>Here is the nested formula that got me the logic for a roster.</p>
<p>=IF($X5>=AJ$4,$X$4,IF($Y5>=AJ$4,$Y$4,IF($Z5>=AJ$4,$Z$4,IF($AA5>=AJ$4,$AA$4,IF($AB5>=AJ$4,$AB$4, IF($AC5>=AJ$4,$AC$4,IF($AD5>=AJ$4,$AD$4,IF($AE5>=AJ$4,$AE$4,IF($AF5>=AJ$4,$AF$4,$AG$4)))))))))</p>
<p>I then used one formula to generate over 600,000 cells and create a map that looks like this.</p>
<p>=INDEX(data,MATCH(C$1,codes,0),(IF(MOD($A3,VLOOKUP(C$1,Rules!$AH:$AI,2,FALSE))=0,VLOOKUP (C$1,Rules!$AH:$AI,2,FALSE),MOD($A3,VLOOKUP(C$1,Rules!$AH:$AI,2,FALSE))))+2)</p>
<p>I used the VLOOKUP formulas because this was a quick and dirty application, not one that needed to stand the test of time. Also the speed of the calculation wasn’t an issue on my <a href="/node/392">development machine</a>. I would have built more robust formulas if this application was going to see regular use.</p>
<p><a href="http://www.spyjournal.biz/files/image_80.png"><img title="image" height="381" alt="image" src="http://www.spyjournal.biz/files/image_thumb_83.png" width="594" border="0" /></a> </p>
<p><a href="http://www.spyjournal.biz/files/image_79.png"><img title="image" height="129" alt="image" src="http://www.spyjournal.biz/files/image_thumb_82.png" width="244" align="right" border="0" /></a>From here I needed to generate a list of the “weekend” periods from their start date to end date.</p>
<p>It needed to look like the table to the right as this was going to be uploaded into their enterprise system.</p>
<p>Given the large number of cells this had the potential to go below the 65535 rows allowed in Excel 2003.</p>
<p>In the end I only used 58471 rows so was comfortably inside the limit. However if they add more rosters this could break.</p>
<p>I cannot display the code here as it is the intellectual property of the client – as they have paid for it.</p>
<p>The result for the client is huge. Entering 230,000 odd pieces of data into a system manually would have been very tedious.</p>
<p>Generating the 90 odd rosters manually and then uploading them would still have been very tedious and needed to be repeated if there were any problems or errors or new rosters.</p>
<p>This application including the initial consulting, logic development and code writing (there’s only 57 lines including all commenting)  took a little over 2 days. You do the math on how much it saved! The code runs in about 15 seconds on my system. Probably a little more on a less grunty PC. This is the power of Excel and VBA automating repetitive tasks and what we make a lot of money doing!</p>
https://www.spyjournal.biz/developing-excel-2007#commentsExcelIFINDEXMATCHMODVLOOKUPhttps://www.spyjournal.biz/crss/node/932Wed, 15 Oct 2008 02:00:24 +0000jethro932 at https://www.spyjournal.bizDynamic Ranges - and using VBA to create them
https://www.spyjournal.biz/excel/Dynamic_Ranges_and_using_VBA_to_create_them
<p>Andrew recently posted a piece of <a href="http://blog.livedoor.jp/andrewe/archives/50353713.html">VBA code used to create dynamic ranges</a>. Very useful.<br />
Here is my <a href="/exceltips/2004/10/dynamic-range-names.html">original post on dynamic ranges</a> posted back in 2004 repeated.<br />
If you have used a range name before then you will know that it can be frustrating updating the reference of the range name if you want to add data to the range.<br />
Here are some ways you can dynamically update the range by using the OFFSET function in the range name reference.<br />
Assume for all these examples that column A has a mixture of text and numbers for several cells.<br />
Click Insert - Name - Define on the menu.<br />
In the Names in Workbook Dialog box type a range name (Eg test_range) and then try these different options.<br />
<strong>1: Expand Down as Many Rows as There are Numeric Entries.</strong><br />
In the <strong><em>Refers to</em></strong> box type: <strong>=OFFSET($A$1,0,0,COUNT($A:$A),1)</strong><br />
<strong>2: Expand Down as Many Rows as There are Numeric and Text Entries.</strong><br />
In the <strong><em>Refers to</em></strong> box type: <strong>=OFFSET($A$1,0,0,COUNTA($A:$A),1)</strong><br />
<strong>3: Expand Down to The Last Numeric Entry</strong><br />
In the <strong><em>Refers to</em></strong> box type: <strong>=OFFSET($A$1,0,0,MATCH(1E+306,$A:$A))</strong><br />
If you expect a number larger than <strong>1E+306</strong> (a one with 306 zeros) then change this to a larger number.<br />
<strong>4: Expand Down to The Last Text Entry</strong><br />
In the <strong><em>Refers to</em></strong> box type: <strong>=OFFSET($A$1,0,0,MATCH("*",$A:$A,-1))</strong><br />
<strong>5: Expand Down Based on Another Cell Value</strong><br />
Put the number 10 in cell B1 first then:<br />
In the <strong><em>Refers to</em></strong> box type: <strong>=OFFSET($A$1,0,0,$B$1,1)</strong><br />
Now change the number in cell <strong>B1</strong> and the range will change accordingly.<br />
<strong>6: Expand Down One Row Each Month</strong><br />
In the <strong><em>Refers to</em></strong> box type: <strong>=OFFSET($A$1,0,0,MONTH(TODAY()),1)</strong><br />
<strong>7: Expand Down One Row Each Week</strong><br />
In the <strong><em>Refers to</em></strong> box type: <strong>=OFFSET($A$1,0,0,WEEKNUM(TODAY()),1)</strong><br />
Requires the "Analysis Toolpak" to be installed. <strong>Tools>Add-ins-Analysis Toolpak</strong><br />
The good thing about number <strong>3,4,5,6</strong> and <strong>7</strong> is that they will include blank cells.<br />
You can also change the <strong>Columns</strong> the dynamic range will span by simply changing the last <strong>Argument</strong> of the <strong>OFFSET</strong> function to a higher number than 1.<br />
You could even expand across your <strong>Columns</strong> dynamically by placing another <strong>COUNT</strong> or <strong>COUNTA</strong> formula as the last argument, instead of 1. See below:<br />
In the <strong>Refers to</strong> box type: <strong>=OFFSET($A$1,0,0,COUNTA($A:$A),COUNTA($1:$1))</strong><br />
This dynamic range will now also expand across <strong>Columns</strong> in <strong>Row 1</strong>. So if you add another <strong>Column</strong> to your <strong>Table</strong> the dynamic range will automatically incorporate it.<br />
Adapted from <a href="http://www.ozgrid.com/">OzGrid</a></p>
https://www.spyjournal.biz/excel/Dynamic_Ranges_and_using_VBA_to_create_them#commentsAddinCOUNTCOUNTAExcelfunctionsMATCHMONTHOFFSETTODAYVBAWEEKNUMhttps://www.spyjournal.biz/crss/node/149Tue, 30 Oct 2007 05:35:24 +0000jethro149 at https://www.spyjournal.biz