{"id":7819,"date":"2014-12-15T12:18:39","date_gmt":"2014-12-15T19:18:39","guid":{"rendered":"http:\/\/macblaze.ca\/?p=7819"},"modified":"2014-12-15T12:18:39","modified_gmt":"2014-12-15T19:18:39","slug":"favorite-excel-formulas","status":"publish","type":"post","link":"https:\/\/macblaze.ca\/?p=7819","title":{"rendered":"Favorite Excel Formulas"},"content":{"rendered":"<p>Since I originally started this blog to help me keep track of coding and computer-related info, I thought I would write down some of my favourite Excel formulas for posterity. Most of these reside in an excel spreadsheet I have carried with me for over a dozen years but here they are appearing on the internet for the the very first time!<\/p>\n<h4>Last Name First Name<\/h4>\n<p>Simple and prevalent but a lot of people just don&#8217;t understand how handy spreadsheets can be for manipulating textual data and do it the manual way.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Bill to Name<\/strong><\/td>\n<td><strong>First<\/strong><\/td>\n<td><strong>Last<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Blow, Joe<\/td>\n<td>Joe<\/td>\n<td>Blow<\/td>\n<\/tr>\n<tr>\n<td>Simmons, Mike<\/td>\n<td>Mike<\/td>\n<td>Simmons<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Bill to Name<\/strong><\/td>\n<td><strong>First<\/strong><\/td>\n<td><strong>Last<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Blow, Joe<\/td>\n<td>\n<p class=\"p1\">=RIGHT(<span class=\"s1\">A2<\/span>,<span class=\"s2\">(<\/span>LEN<span class=\"s3\">(<\/span><span class=\"s1\">A2<\/span><span class=\"s3\">)<\/span>-SEARCH<span class=\"s3\">(<\/span>&#8220;,&#8221;,<span class=\"s1\">A2<\/span>,1<span class=\"s3\">)<\/span><span class=\"s2\">)<\/span>-1)<\/p>\n<\/td>\n<td>\n<p class=\"p1\">=LEFT(<span class=\"s1\">A2<\/span>,SEARCH<span class=\"s2\">(<\/span>&#8220;,&#8221;,<span class=\"s1\">A2<\/span>,1<span class=\"s2\">)<\/span>-1)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>Simmons, Mike<\/td>\n<td>\n<p class=\"p1\">=RIGHT(<span class=\"s1\">A3<\/span>,<span class=\"s2\">(<\/span>LEN<span class=\"s3\">(<\/span><span class=\"s1\">A3<\/span><span class=\"s3\">)<\/span>-SEARCH<span class=\"s3\">(<\/span>&#8220;,&#8221;,<span class=\"s1\">A3<\/span>,1<span class=\"s3\">)<\/span><span class=\"s2\">)<\/span>-1)<\/p>\n<\/td>\n<td>\n<p class=\"p1\">=LEFT(<span class=\"s1\">A3<\/span>,SEARCH<span class=\"s2\">(<\/span>&#8220;,&#8221;,<span class=\"s1\">A3<\/span>,1<span class=\"s2\">)<\/span>-1)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>A few things to know about\u00a0calculations<\/p>\n<ul>\n<li>they all start with the &#8220;=&#8221; sign.<\/li>\n<li>calculations are often made up of many, nested, formulae.<\/li>\n<li>you refer to specific cells by their coordinates in the grid. &#8220;A2&#8221; refers to the cell in column A, row 2<\/li>\n<li>spreadsheet calculations\u00a0are hierarchical, just like you learned in grade school. So brackets and nesting brackets are important. The spreadsheet will solve for the deepest level first and then work outwards.<\/li>\n<li>Things in quotes are treated as text; things not in quotes are treated as elements of the formula.<\/li>\n<li>Data elements\u00a0within\u00a0a formula are separated by commas<\/li>\n<\/ul>\n<p>So, in the above, you first need to visualize the problem. Essentially I want everything after\u00a0the comma to go in column 2 and everything before the comma to go in column 2. So that means first finding the position of the comma.<\/p>\n<p class=\"p1\">=SEARCH(&#8220;,&#8221;,<span class=\"s1\">A2<\/span>,1)<br \/>\nsearch (for a comma &#8220;,&#8221;, in cell A2, and\u00a0look for the first one to appear)<\/p>\n<p class=\"p1\">The syntax for this formula and all the others that Excel uses can be found by hitting the <strong>fx<\/strong> button right by the formula bar\u2014there are a bazillion of them. Once you&#8217;ve found the comma you can then grab everything to the right (or left) of it. To do that you need to subtract the position of the comma from the overall length of cell A2.<\/p>\n<p class=\"p1\">=LEN<span class=\"s3\">(<\/span><span class=\"s1\">A20)<\/span>-COMMA POSITION<\/p>\n<p class=\"p1\">To compensate for the space between the \u00a0comma and the first name you add a -1 \u2014 be sure to remember the brackets because you are subtracting the 1 from the whole calculation.<\/p>\n<p class=\"p1\">=(LEN<span class=\"s3\">(<\/span><span class=\"s1\">A2<\/span><span class=\"s3\">)<\/span>-COMMA POSITION<span class=\"s2\">)-1<\/span><\/p>\n<p class=\"p1\">So now you have the elements necessary to use the right formula whose syntax\u00a0calls is\u00a0Right(text, number of characters).<\/p>\n<p class=\"p1\">=right(A2, (length-comma position)-1) or<br \/>\n=RIGHT(<span class=\"s1\">A2<\/span>,<span class=\"s2\">(<\/span>LEN<span class=\"s3\">(<\/span><span class=\"s1\">A2<\/span><span class=\"s3\">)<\/span>-SEARCH<span class=\"s3\">(<\/span>&#8220;,&#8221;,<span class=\"s1\">A2<\/span>,1<span class=\"s3\">)<\/span><span class=\"s2\">)<\/span>-1)<\/p>\n<p class=\"p1\">To find the last name is almost the same but using the Left\u00a0formula, which has similar syntax to RIGHT. It&#8217;s a bit easier because you don&#8217;t have to subtract from the length to find the number of characters. You still have to subtract 1 to account for the comma itself.<\/p>\n<p class=\"p1\">=left(A2,position of the comma-1) or<br \/>\n=LEFT(<span class=\"s1\">A32<\/span>,SEARCH<span class=\"s2\">(<\/span>&#8220;,&#8221;,<span class=\"s1\">A2<\/span>,1<span class=\"s2\">)<\/span>-1)<\/p>\n<p class=\"p1\">Simple huh? I know, I know, it is complex and mind numbing. That&#8217;s why I generally figure\u00a0these calcs once, store them in a master spreadsheet and then reuse them when necessary. Remember that Excel&#8217;s fill down command will allow you to repeat the calculation for as many rows as you need and will automatically update the cell numbers to accommodate you.<\/p>\n<h4 class=\"p1\">Putting it Back<\/h4>\n<p>Changing it back is even easier.<\/p>\n<table style=\"border-collapse: collapse; width: 195pt;\" border=\"0\" width=\"195\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 65pt;\" span=\"3\" width=\"65\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt; width: 65pt;\" width=\"65\" height=\"13\"><strong>First<\/strong><\/td>\n<td style=\"width: 65pt;\" width=\"65\"><strong>Last<\/strong><\/td>\n<td style=\"width: 65pt;\" width=\"65\"><strong>Bill To Name<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt; width: 65pt;\" width=\"65\" height=\"13\">Frank<\/td>\n<td style=\"width: 65pt;\" width=\"65\">Jones<\/td>\n<td style=\"width: 65pt;\" width=\"65\">Jones, Frank<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"p1\">=B2<span class=\"s1\">\u00a0<\/span>&amp; &#8220;, &#8221; &amp; A<span class=\"s2\">2<\/span><\/p>\n<p class=\"p1\">Cell C2 is equal to cell B2 plus a comma and a space (in quotes because they are text not data) and then cell A2. Simple!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since I originally started this blog to help me keep track of coding and computer-related info, I thought I would write down some of my favourite Excel formulas for posterity. Most of these reside in an excel spreadsheet I have carried with me for over a dozen years but here they are appearing on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/7819"}],"collection":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7819"}],"version-history":[{"count":0,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/7819\/revisions"}],"wp:attachment":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}