Spy Journal 3.0 - IF
https://www.spyjournal.biz/taxonomy/term/83/all
enHow to remove #N/A errors in Excel
https://www.spyjournal.biz/how-remove-na-errors-excel
<p>Today I had an email request:</p>
<blockquote><p>I wasn't sure how to post, or join so I'm sending my question to you this way. I cannot figure out how to remove the #N/A error in LOOKUP. If the cells are blank it returns the #N/A error - I'd like to return either a blank or 0 instead. How do I do that? Her is my formula. (I'm sure you can tell by my formula I'm a rookie at this.) Any help is appreciated. Thanks!</p>
<p>=SUM((LOOKUP(B6,{1,2,3,4,5},{40,30,20,10,0}))+(LOOKUP(C6,{1,2,3,4,5},{40,30,20,10,0})+(LOOKUP(D6,{1,2,3,4,5},{40,30,20,10,0})+(LOOKUP(E6,{1,2,3,4,5},{40,30,20,10,0})+(LOOKUP(F6,{1,2,3,4,5},{40,30,20,10,0}))))))</p>
</blockquote>
<p><a href="http://www.spyjournal.biz/files/Excel-2013.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="Excel-2013" border="0" alt="Excel-2013" align="left" src="http://www.spyjournal.biz/files/Excel-2013_thumb.png" width="120" height="120" /></a>I have written a post on this before when I explained the <a href="http://www.spyjournal.biz/excel-function-week-isna" target="_blank">ISNA function</a>.</p>
<p>In this case I will break down the first component of the formula and show you how to insert it.</p>
<p>First of all understand that because this formula is summing components that are lookups, if any one of them returns an error than the overall sum will be an error even if the rest is not an error.</p>
<p>So to fix =LOOKUP(B6,{1,2,3,4,5},{40,30,20,10,0}) when it displays #N/A (eg if B6 is less than 1) we would use this function:</p>
<p>=IF(ISNA(LOOKUP(B6,{1,2,3,4,5},{40,30,20,10,0}))=TRUE,0,LOOKUP(B6,{1,2,3,4,5},{40,30,20,10,0}))</p>
<p>The same concept could be used for each lookup component. In this case the formula would become very involved so there might be easier ways to do it. Sometimes breaking the individual components our into individual cells and then summing them is a way to give more visible results – and easily see which component is causing the error.</p>
<p>So Lois – i hope that helps – and thanks for <a href="http://www.facebook.com/spyjournal.biz" target="_blank">liking us on Facebook</a>!</p>
<!--break--><!--break-->https://www.spyjournal.biz/how-remove-na-errors-excel#commentsExcelfunctionsIFISNAhttps://www.spyjournal.biz/crss/node/1295Fri, 14 Dec 2012 02:21:11 +0000jethro1295 at https://www.spyjournal.bizA practical way to use the IF function in Excel
https://www.spyjournal.biz/practical-way-use-if-function-excel
<p>The IF function is a very useful logical tool. I have written an <a href="http://www.spyjournal.biz/node/937">explanation on the IF Function</a> before so I wont repeat that here. There are a number of other posts also that incorporate <a href="http://www.spyjournal.biz/taxonomy/term/83/all">the use of the IF Function</a>.</p>
<p><a href="http://www.spyjournal.biz/files/Excel_5.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="Excel" border="0" alt="Excel" align="right" src="http://www.spyjournal.biz/files/Excel_thumb_4.png" width="100" height="100" /></a>What I want to do is highlight a useful way to use the IF function.</p>
<p>I use it a lot to compare lists of data. today I had been sent some data in a spread sheet that contained email addresses. I had to create a mail out to those email addresses and when i did that I received a number of bounce backs for incorrect email addresses. I then received a second email from the original person containing a revised spread sheet with the corrections to email addresses. given that there were a large number of addresses and only a few changes I didn’t want to painstakingly work my way through the list looking for changes. Instead I copied the new list beside the old list and then wrote an if statement to compare the original with the revised. It is very simple and uses a 1 or 0 result. You could use anything there including TRUE or FALSE or “OK” and “ERROR” etc. Then a simple filter showed me the incorrect ones and the fixes i needed to apply in my mailing list.</p>
<p>Obviously I have obfuscated the email addresses in this example for privacy reasons.</p>
<p>The actual IF statement is very simple. In Cell C1 I wrote =IF(B2=A2,0,1). Filling it down is as simple as double-clicking the right hand bottom corner of the cell. </p>
<p><a href="http://www.spyjournal.biz/files/image_211.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_213.png" width="598" height="185" /></a></p>
<p>Then I added a simple filter to hide the correct results and only display those with differences.</p>
<p><a href="http://www.spyjournal.biz/files/image_212.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_214.png" width="295" height="402" /></a></p>
<p>I use this technique many times a week in comparing data lists.</p>
<!--break--><!--break-->https://www.spyjournal.biz/practical-way-use-if-function-excel#commentsdata filtersExcelfunctionsIFExcelhttps://www.spyjournal.biz/crss/node/1275Fri, 25 May 2012 01:09:14 +0000jethro1275 at https://www.spyjournal.bizExcel function of the week - AND
https://www.spyjournal.biz/excel-function-week-and
<p>The AND function takes each of the conditions inside the brackets and evaluates for their truth, and then multiplies the results together. TRUE = 1 and FALSE = 0. So if any condition is FALSE then the overall statement returns FALSE.</p>
<p>The formula for AND needs to be placed in brackets with each of the conditions separated by a comma. For example =AND(H1<1,G1>1)</p>
<p>In this instance the function will evaluate H1 to see if the value is less than 1. if it is then it will return TRUE or 1 and if not FALSE or 0. Then it will do the same for G1. <br />The two values are multiplied together and the answer is then either 1 or 0, TRUE or FALSE.</p>
<p>The Excel Help says:</p>
<blockquote><p>One common use for the <b>AND</b> function is to expand the usefulness of other functions that perform logical tests. For example, the <b><a href="http://www.spyjournal.biz/node/937">IF</a></b> function performs a logical test and then returns one value if the test evaluates to TRUE and another value if the test evaluates to FALSE. By using the <b>AND</b> function as the<b><i> logical_test</i></b> argument of the <b><a href="http://www.spyjournal.biz/node/937">IF</a></b> function, you can test many different conditions instead of just one.</p>
</blockquote>
<p><a href="http://www.spyjournal.biz/files/image_162.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_164.png" width="594" height="338" /></a></p>
<!--break--><!--break-->https://www.spyjournal.biz/excel-function-week-and#commentsANDExcelfunctionsIFhttps://www.spyjournal.biz/crss/node/1237Wed, 22 Dec 2010 23:28:23 +0000jethro1237 at https://www.spyjournal.bizRelative conditional formatting in Excel 2007
https://www.spyjournal.biz/relative-conditional-formatting-excel-2007
<p>I had a reader request some help with Conditional Formatting in Excel 2007.</p>
<blockquote><p>Hi</p>
<p>Baffled in trying to get to grips with conditional formating in 2007 </p>
<p>Scenario : </p>
<p>Column A = Actual Result <br />Column B = Target <br />Column C = Needs to show <br />1) If Actual result is less than 90% of target turn font colour RED <br />2) If Actual result is >90% of target and is <100% of target turn font colour AMBER <br />3) If Actual result is >= 100% of target turn font colour GREEN </p>
<p>If column C meets criteria 1 use character "R", criteria 2 = "A" and criteria 3 = "G"</p>
<p>I can acheive 1 and 3 with =IF(a1b1,"G")) and then conditional format so that if contents of cell = R or G then colour font accordingly </B1,"R",IF(A1></p>
<p>I`m stumped with the % factor and also think there might be a better way of doing it</p>
<p>Any help would be appreciated :)</p>
</blockquote>
<p>Here is a solution to this problem.</p>
<p>We formatted two columns to give two examples as to how it could be done.</p>
<p>The actual column determines the percentage as part of the conditional format and formats in that way.</p>
<p>The result column formats on the “R”, “A”, and “G”.</p>
<p><a href="http://www.spyjournal.biz/files/image_158.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_160.png" width="220" height="184" /></a> The formula in Column C1 is =IF(A2/B2<1,IF(A2/B2<0.9,"R","A"),"G") and this can be copied down.</p>
<p>Here are the rules for Column A</p>
<p><a href="http://www.spyjournal.biz/files/image_159.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_161.png" width="594" height="292" /></a> </p>
<!--break--><!--break--><p>And here are the rules for Column C</p>
<p><a href="http://www.spyjournal.biz/files/image_160.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.spyjournal.biz/files/image_thumb_162.png" width="594" height="292" /></a> </p>
<p>Thanks to <a href="http://www.nicholasperkins.com/">Nick</a> who works for me for developing this solution for me.</p>
https://www.spyjournal.biz/relative-conditional-formatting-excel-2007#commentsconditional formattingExcelIFhttps://www.spyjournal.biz/crss/node/1225Mon, 19 Jul 2010 22:23:21 +0000jethro1225 at https://www.spyjournal.bizExcel Tools and News from the web
https://www.spyjournal.biz/excel-tools-and-news-web
<p>I have had a bunch of pretty cool Excel things to post up – and finally got around to clearing my flagged items and browser windows.</p>
<h3>Conditional Formatting</h3>
<p><a href="http://www.spyjournal.biz/files/excel2007_0.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="excel 2007" border="0" alt="excel 2007" align="right" src="http://www.spyjournal.biz/files/excel2007_thumb_0.jpg" width="111" height="113" /></a>I have written a couple of articles on Conditional formatting in Excel 2007 with lots of readers comments and requests for help. They are the two most read articles on this site.</p>
<ul>
<li><a href="http://www.spyjournal.biz/conditional_format_Excel2007">Conditional formatting in Excel 2007 - entire row colours</a></li>
<li><a href="http://www.spyjournal.biz/conditionalformat_excel2007">Excel 2007 Conditional Formatting</a></li>
</ul>
<p>I was very interested then to come across this article on Joseph’s site by Amit Velingkar where he shows you <a href="http://blogs.msdn.com/excel/archive/2009/04/16/modifying-conditional-formatting-color-ranges-in-excel-2007.aspx">how to change the automatic colour ranges that are used in Excel 2007 for conditional formatting</a>. He even includes some VBA code for this.</p>
<!--break--><!--break--><h3>VLOOKUP</h3>
<p> Dick Kusleika has posted some pretty interesting information about <a href="http://www.dailydoseofexcel.com/archives/2009/04/20/vlookup/">trapping #N/A errors using the VLOOKUP formula in Excel 2007 compared to Excel 2003</a>. </p>
<blockquote><p><strong>In Excel 2003</strong>, the best way to capture this error, is to use the ISNA worksheet function, such as in this example:</p>
<p><code>=IF(ISNA(VLOOKUP("XYZ", MyTable, 2, FALSE)),"",VLOOKUP("XYZ", MyTable, 2, FALSE))</code></p>
<p>This checks to see if the formula returns the NA error and, if so, returns an empty string (to look like a blank cell). There is a big downside to this: For each cell this is used in, Excel has to calculate the VLOOKUP function twice. If you have a lot of them, it can really slow things down. Unfortunately, I don’t know of a better way.</p>
<p><strong>In Excel 2007</strong>, however, a new worksheet function was introduced. IFERROR not only shortens your formulas, but can speed up calculations. In 2007, it looks like this:</p>
<p><code>=IFERROR(VLOOKUP("XYZ", MyTable, 2, FALSE),"")</code></p>
</blockquote>
<p>He also does a very good comparison of <a href="http://www.dailydoseofexcel.com/archives/2009/04/21/vlookup-on-two-columns/">VLOOKUP, SUMPRODUCT and INDEX</a> when trying to lookup on two columns.</p>
<h3>3 days to go for this Competition!</h3>
<p>MSDN® is sponsoring a coding contest for Office 2007, named <a href="http://blogs.msdn.com/officepalooza">OfficePalooza</a>! This sweepstakes will run two weeks beginning April 20, 2009, and features ten fun Visual Basic of Applications™ (VBA) coding challenges in the form of puzzles and games. Each entrant will earn a chance to win one of hundreds of available prizes, determined by a random drawing at the end of the contest.</p>
<h3>Hierarchical Lists</h3>
<p>Dany Hoter has produced an elegant solution to a very common problem with hierarchical lists.</p>
<blockquote><p><strong>The problem:</strong> Validating data entry based on hierarchical (parent child) data. The example used is regions and countries but it could be countries and cities, product categories and sub-categories, class and student name, etc.</p>
<p>You want to enter a region from a list of regions and in the next cell you want to select a country but only from the countries which belong to that region.</p>
</blockquote>
<p>Go to <a href="http://blogs.msdn.com/excel/archive/2009/03/05/creating-dynamic-validation-ranges.aspx">Joseph Chirilov’s site to read the instructions and download the sample file</a>. I tried it – it works very well – and we will be including this solution from now on when needing to do this.</p>
https://www.spyjournal.biz/excel-tools-and-news-web#commentsconditional formattingExcelIFIFERRORINDEXISNASUMPRODUCTVBAVLOOKUPhttps://www.spyjournal.biz/crss/node/1089Fri, 01 May 2009 01:01:50 +0000jethro1089 at https://www.spyjournal.bizExcel Function of the Week - IF
https://www.spyjournal.biz/excel-function-week-if
<p>I have decided to write a short post once a week looking at a single Excel function. This week we are going to look at the IF function.</p>
<p><strong><a href="http://www.spyjournal.biz/files/clip_image001.png"><img title="clip_image001" height="316" alt="clip_image001" src="http://www.spyjournal.biz/files/clip_image001_thumb.png" width="594" border="0" /></a></strong></p>
<p><strong>Definition from Excel Help</strong></p>
<p>The IF function returns one value if a condition you specify evaluates to TRUE, and another value if that condition evaluates to FALSE. For example, the formula =IF(A1>10,"Over 10","10 or less") returns "Over 10" if A1 is greater than 10, and "10 or less" if A1 is less than or equal to 10.</p>
<p><strong>Syntax</strong></p>
<p>IF(logical_test, value_if_true, [value_if_false])</p>
<p><strong>My explanation</strong></p>
<p>The IF function is best thought of as a solution to “either - or” scenarios. Here are some good examples with the syntax to use for each one.</p>
<ul>
<li>If you are dividing by an number ant it could be zero, the result will be a #DIV/0 error. In this case you can use an IF function to determine if the number you are dividing by is either zero or something else. <strong>=IF(B1=0,0,A1/B1)</strong></li>
<li>If you are wanting to analyse a cell for positive or negative values, eg either a value greater than zero or less than zero. <strong>=IF(A1>=0,”Positive”,”Negative”)</strong></li>
<li>If you are wanting to see if a either a cell is empty or it isn’t empty. <strong>=IF(A1=””,”Empty”,”Not Empty”)</strong></li>
</ul>
<p>All these are great examples and highlight the use of IF. Of course where I have used text results such as “Positive” or “Empty” you can put formulas using other functions, links to other cells or even nest another IF function.</p>
<p>There is a limit to the number of nested IF statements you can use. In Excel 2003 and earlier it was 7. In Excel 2007 it is 64 which is a great improvement.</p>
https://www.spyjournal.biz/excel-function-week-if#commentsExcelIFExcelhttps://www.spyjournal.biz/crss/node/937Mon, 20 Oct 2008 09:24:15 +0000jethro937 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.bizFinding MAX date with an Array Formula in Excel
https://www.spyjournal.biz/max_date_array_formula
<p>Last week I was struggling with getting an array formula to work properly with the MAX function.<br />
I had a column of business units, a column of dates and a status column.<br />
I wanted to find the most recent date for any given business unit where the status was a particular criteria.<br />
I did try using <a href="http://www.xldynamic.com/source/xld.SUMPRODUCT.html">Bob Phillip's sum product page</a> and <a href="http://www.cpearson.com/excel/ArrayFormulas.aspx">Chris Pearson's array formulas page</a>, but it still wasn't working right. Fortunately Bob emailed me with the answer and explained it very well. (I was missing the IF function).<br />
Heres the formula and what Bob said about it:<br />
=MAX(IF((criteria_range1="criteria1")* (criteria_range2="criteria2")* (criteria_range3="criteria3"), date_range))</p>
<blockquote><p>
If a cell in criteria_range1 meets that condition, it returns TRUE. If a cell in criteria_range2 meets that condition it too returns TRUE. Two TRUEs in the same row, which is AND, multiplied together give 1, any combination of FALSE/FALSE, FALSE/TRUE, TRUE/FALSE gives 0. Any non-zero amount is treated as True by Excel, 0 as False, so date_range evaluates to either its value or the non-true condition (False here as we don't have one). So you get a total array of value in date_range where all conditions are met, and False values, allowing MAX to do its bit on. As you can imagine, this works no matter how many conditions there are.
</p></blockquote>
<p><strong>My Notes:</strong><br />
The formula must be committed with CTRL SHIFT ENTER which puts the curly braces {} around the formula.<br />
The criteria ranges must all be the same shape (in this case 1 column wide by the same number of rows deep. I also used dynamic range names.)<br />
The "criteria" can be text or values entered in the formula inside "", or can be a cell reference to the criteria.</p>
https://www.spyjournal.biz/max_date_array_formula#commentsarray formulasExcelfunctionsIFMAXhttps://www.spyjournal.biz/crss/node/97Mon, 08 Oct 2007 22:15:14 +0000jethro97 at https://www.spyjournal.biz