{"id":7822,"date":"2014-12-16T12:18:53","date_gmt":"2014-12-16T19:18:53","guid":{"rendered":"http:\/\/macblaze.ca\/?p=7822"},"modified":"2014-12-15T13:31:30","modified_gmt":"2014-12-15T20:31:30","slug":"more-favorite-excel-formulas","status":"publish","type":"post","link":"https:\/\/macblaze.ca\/?p=7822","title":{"rendered":"More Favorite Excel Formulas"},"content":{"rendered":"<h4>Making Headings<\/h4>\n<p>Quite often I would have columns of headings but when I went to export the headings, I would only want the first instance to appear in the text I was using. For example if I was doing a list of recipes and they were divided up into Chicken, Beef and Seafood, I would like the heading &#8220;Chicken&#8221; to appear only before the first entry\u2014think Table of Contents.<\/p>\n<p>Thus:<\/p>\n<table width=\"300\">\n<tbody>\n<tr>\n<td>Chicken<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr>\n<td>Chicken<\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr>\n<td>Chicken<\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr>\n<td>Beef<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr>\n<td>Beef<\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Seafood<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr>\n<td>Seafood<\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr>\n<td>Seafood<\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>Should be:<\/p>\n<table width=\"300\">\n<tbody>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt; width: 65pt;\" width=\"65\" height=\"13\">Chicken<\/td>\n<td style=\"width: 65pt;\" width=\"65\">Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">Beef<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">Seafood<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Again the first thing you ned to do is visualize the problem and then express it logically. If the heading is the same as\u00a0the\u00a0heading above then don&#8217;t show it. If it is not the same then do show it. I also threw in a bit to accommodate the space between Beef and Seafood in case it was necessary.<\/p>\n<p>The first thing you need to do is insert a new column between the headings (column A) and the recipes (column B). Actually you can make the new column for the calculation anywhere you want but it is much easier to keep alongside the original.<\/p>\n<table width=\"356\">\n<tbody>\n<tr>\n<td width=\"226\"><strong>A<\/strong><\/td>\n<td width=\"65\"><strong>B<\/strong><\/td>\n<td width=\"65\"><strong>C<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Chicken<\/td>\n<td><\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr>\n<td>Chicken<\/td>\n<td><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr>\n<td>Chicken<\/td>\n<td><\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr>\n<td>Beef<\/td>\n<td><\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr>\n<td>Beef<\/td>\n<td><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Seafood<\/td>\n<td><\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr>\n<td>Seafood<\/td>\n<td><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr>\n<td>Seafood<\/td>\n<td><\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"p1\">Then you fill column B with the following formula:<\/p>\n<p class=\"p1\">=IF(<span class=\"s1\">A2<\/span>=&#8221;&#8221;,&#8221;&#8221;,<span class=\"s2\">(<\/span>IF<span class=\"s3\">(<\/span><span class=\"s1\">A2<\/span>=<span class=\"s2\">A1<\/span>,&#8221;&#8221;,<span class=\"s1\">A2<\/span><span class=\"s3\">)<\/span><span class=\"s2\">)<\/span>)<\/p>\n<p class=\"p1\">This is constructed from\u00a0basic <em>if statements<\/em>. You will use them a lot if you spend any amount of time working with formulas and calculations. The syntax for an if statement is \u00a0IF(logical test, is true then do this&#8230;, else do this&#8230;) So this =IF(a=b,&#8221;A&#8221;,&#8221;B&#8221;) simply put, is \u00a0read as if a is equal to b then write A, if not then write B. My formula above uses two nested if statements, one that checks to see if the current row is blank or not and one that determines whether it is the same as the row above.<\/p>\n<p class=\"p1\">Is the row empty? If so then leave it blank; if not then go on to the rest of the calculation. Empty (blank) is indicated by two quotes with nothing (not even a space) between them.<\/p>\n<p class=\"p1\">=IF(A2=&#8221;&#8221;, &#8220;&#8221;,\u00a0next if statement)<\/p>\n<p class=\"p1\">The next if statement then decided if the current cell matches the one above or not. If it does, if leaves it blank. If it doesn&#8217;t then it put in the text from the current cell.<\/p>\n<p class=\"p1\">=IF(A2=A1,&#8221;&#8221;,A2)<\/p>\n<p class=\"p1\">All together:<\/p>\n<p class=\"p1\">=IF(<span class=\"s1\">A2<\/span>=&#8221;&#8221;,&#8221;&#8221;,<span class=\"s2\">(<\/span>IF<span class=\"s3\">(<\/span><span class=\"s1\">A2<\/span>=<span class=\"s2\">A1<\/span>,&#8221;&#8221;,<span class=\"s1\">A2<\/span><span class=\"s3\">)<\/span><span class=\"s2\">)<\/span>)<\/p>\n<p class=\"p1\">If cell A2 is blank then leave blank space, if not then see if A2 is equal to the cell above (A1). If it is, then again leave a blank space. If not, then write in the contents of A2.<\/p>\n<p class=\"p1\">One thing to remember about this sort of thing is the calculations are all related to the original list. If you delete column A\u2014which you will likely have to if you are going to export it to a text file\u2014then the text in your column B will also disappear. The easiest away around this is, just before you delete the column, you copy column C and then paste it right back using Edit: Paste Special, then select Text. This will paste not the column of formulae you cut, but the results in text form\u2014perfect for exporting!<\/p>\n<h4 class=\"p1\">But I need to get rid of Headers<\/h4>\n<p>Just as often I would find that to manipulate the text, it would be easier to not have these headers, but rather the filled in columns (think sorting by header) so how do you do this the other way? Well, there&#8217;s a formula for that!<\/p>\n<p>Turning:<\/p>\n<table width=\"300\">\n<tbody>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt; width: 65pt;\" width=\"65\" height=\"13\">apple<\/td>\n<td style=\"width: 65pt;\" width=\"65\">Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 4<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">oranges<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">bananas<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 4<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\"><\/td>\n<td>Recipe 5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"p1\">Into:<\/p>\n<table width=\"300\">\n<tbody>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt; width: 65pt;\" width=\"65\" height=\"13\">apple<\/td>\n<td style=\"width: 65pt;\" width=\"65\">Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">apple<\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">apple<\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">apple<\/td>\n<td>Recipe 4<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">oranges<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">oranges<\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">oranges<\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">bananas<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">bananas<\/td>\n<td>Recipe 2<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">bananas<\/td>\n<td>Recipe 3<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">bananas<\/td>\n<td>Recipe 4<\/td>\n<\/tr>\n<tr style=\"height: 13.0pt;\">\n<td style=\"height: 13.0pt;\" height=\"13\">bananas<\/td>\n<td>Recipe 5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"p1\">You begin by once again adding in a new column for the calculation and then filling it with the following:<\/p>\n<p class=\"p1\">=(IF<span class=\"s1\">(<\/span><span class=\"s2\">A2<\/span>=&#8221;&#8221;,<span class=\"s1\">B1<\/span>,<span class=\"s2\">A2<\/span><span class=\"s1\">)<\/span>)<\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td><strong>A<\/strong><\/td>\n<td><strong>B<\/strong><\/td>\n<td><strong>C<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>1<\/strong><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><strong>2<\/strong><\/td>\n<td>apple<\/td>\n<td>=(IF(A2=&#8221;&#8221;,B1,A2)<\/td>\n<td>Recipe 1<\/td>\n<\/tr>\n<tr>\n<td><strong>3<\/strong><\/td>\n<td><\/td>\n<td>=(IF(A3=&#8221;&#8221;,B2,A3)<\/td>\n<td>Recipe\u00a02<\/td>\n<\/tr>\n<tr>\n<td><strong>4<\/strong><\/td>\n<td><\/td>\n<td>=(IF(A4=&#8221;&#8221;,B3,A4)<\/td>\n<td>Recipe\u00a03<\/td>\n<\/tr>\n<tr>\n<td><strong>5<\/strong><\/td>\n<td><\/td>\n<td>=IF(A5=&#8221;&#8221;,&#8221;B4,A4)<\/td>\n<td>Recipe\u00a04<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In order to make this work you need to have a blank row above your first row so \u00a0the calc can always reference the row above. So this calculation says if the row to the left is empty, then make\u00a0this cell the same as the one above it. If it isn&#8217;t empty then make this cell the same as the one to the left. Again remember that to do any sorting or manipulation you first need to change column C from a set of calculations to actual text data (by Paste Special) otherwise changing the order will just make it recalculate based on the new data in the column to the left.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Making Headings Quite often I would have columns of headings but when I went to export the headings, I would only want the first instance to appear in the text I was using. For example if I was doing a list of recipes and they were divided up into Chicken, Beef and Seafood, I would [&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\/7822"}],"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=7822"}],"version-history":[{"count":0,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/7822\/revisions"}],"wp:attachment":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}