{"id":707,"date":"2019-02-28T10:54:46","date_gmt":"2019-02-28T16:54:46","guid":{"rendered":"http:\/\/www.iqaccountingsolutions.com\/blog\/?p=707"},"modified":"2019-03-22T22:09:52","modified_gmt":"2019-03-23T03:09:52","slug":"hide-divide-by-zero-errors-in-excel-using-if","status":"publish","type":"post","link":"https:\/\/www.iqaccountingsolutions.com\/blog\/hide-divide-by-zero-errors-in-excel-using-if\/","title":{"rendered":"Hide Divide By Zero Errors in Excel Using IF"},"content":{"rendered":"<p>You should all remember from math class that you can&#8217;t divide a number by zero. When you try to do it in Excel, the result of your formula will be <em>#DIV\/0!<\/em>. In some cases this is inevitable. For example if your spreadsheet calculates percentage change in annual sales of inventory items, new items will produce a <em>#DIV\/0!<\/em> error because prior year sales are zero.<\/p>\n<p>&nbsp;<\/p>\n<table border=\"1\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"25\"><\/td>\n<td width=\"77\">\n<p align=\"center\">A<\/p>\n<\/td>\n<td>\n<p align=\"center\">B<\/p>\n<\/td>\n<td>\n<p align=\"center\">C<\/p>\n<\/td>\n<td>\n<p align=\"center\">D<\/p>\n<\/td>\n<td>\n<p align=\"center\">E<\/p>\n<\/td>\n<td width=\"213\">Column E Formula<\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td width=\"77\"><\/td>\n<td width=\"110\">\n<p align=\"center\">Year 1 Sales<\/p>\n<\/td>\n<td width=\"110\">\n<p align=\"center\">Year 2 Sales<\/p>\n<\/td>\n<td width=\"110\">\n<p align=\"center\">$ Change<\/p>\n<\/td>\n<td width=\"114\">\n<p align=\"center\">% Change<\/p>\n<\/td>\n<td width=\"213\"><\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">2<\/p>\n<\/td>\n<td width=\"77\">Item 1<\/td>\n<td width=\"110\">10,000<\/td>\n<td width=\"110\">11,000<\/td>\n<td width=\"110\">1,000<\/td>\n<td width=\"114\">10%<\/td>\n<td width=\"213\">=D2\/B2<\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">3<\/p>\n<\/td>\n<td width=\"77\">Item 2<\/td>\n<td width=\"110\">0<\/td>\n<td width=\"110\">7,000<\/td>\n<td width=\"110\">7,000<\/td>\n<td width=\"114\">#DIV\/0!<\/td>\n<td width=\"213\">=D3\/B3<\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td width=\"77\">Item 3<\/td>\n<td width=\"110\">15,000<\/td>\n<td width=\"110\">12,000<\/td>\n<td width=\"110\">(3,000)<\/td>\n<td width=\"114\">-20%<\/td>\n<td width=\"213\">=D4\/B4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As expected, the % Change for Item 2 shows a divide by zero error because it had no sales in year 1. Excel does not have an option to suppress divide by zero errors, but it&#8217;s easily by done using the <em>IF<\/em> function. If you haven&#8217;t used <em>IF<\/em> before, it may help to read my <a href=\"http:\/\/iqaccountingsolutions.us2.list-manage2.com\/track\/click?u=0b92990bba1267be26b8ca6db&amp;id=834113d960&amp;e=b0476d6293\">previous tip<\/a> on that subject. The formula below tells Excel, <em>if the prior year sales (for Item 2 that&#8217;s cell B3) is zero, then display the text between the quotation marks (in this case nothing), if not, divide the $ Change by Year 1 Sales.<\/em> The result is that the % Change appears blank for item 2 but for items 1 and 3 it looks the same as with the original formula.<\/p>\n<p>&nbsp;<\/p>\n<table border=\"1\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"25\"><\/td>\n<td width=\"77\">\n<p align=\"center\">A<\/p>\n<\/td>\n<td>\n<p align=\"center\">B<\/p>\n<\/td>\n<td>\n<p align=\"center\">C<\/p>\n<\/td>\n<td>\n<p align=\"center\">D<\/p>\n<\/td>\n<td>\n<p align=\"center\">E<\/p>\n<\/td>\n<td width=\"213\">Column E Formula<\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td width=\"77\"><\/td>\n<td width=\"110\">\n<p align=\"center\">Year 1 Sales<\/p>\n<\/td>\n<td width=\"110\">\n<p align=\"center\">Year 2 Sales<\/p>\n<\/td>\n<td width=\"110\">\n<p align=\"center\">$ Change<\/p>\n<\/td>\n<td width=\"114\">\n<p align=\"center\">% Change<\/p>\n<\/td>\n<td width=\"213\"><\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">2<\/p>\n<\/td>\n<td width=\"77\">Item 1<\/td>\n<td width=\"110\">10,000<\/td>\n<td width=\"110\">11,000<\/td>\n<td width=\"110\">1,000<\/td>\n<td width=\"114\">10%<\/td>\n<td width=\"213\">=IF(B2=0,&#8221;&#8221;,D2\/B2)<\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">3<\/p>\n<\/td>\n<td width=\"77\">Item 2<\/td>\n<td width=\"110\">0<\/td>\n<td width=\"110\">7,000<\/td>\n<td width=\"110\">7,000<\/td>\n<td width=\"114\"><\/td>\n<td width=\"213\">=IF(B3=0,&#8221;&#8221;,D3\/B3)<\/td>\n<\/tr>\n<tr>\n<td width=\"25\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td width=\"77\">Item 3<\/td>\n<td width=\"110\">15,000<\/td>\n<td width=\"110\">12,000<\/td>\n<td width=\"110\">(3,000)<\/td>\n<td width=\"114\">-20%<\/td>\n<td width=\"213\">=IF(B4=0,&#8221;&#8221;,D4\/B4)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>I made the % Change blank if Year 1 Sales = 0, but you could show whatever you want.<br \/>\nIf you want to display text when Year 1 Sales = 0 type whatever you want between the quotation marks. In this example you might use <em>=IF(B3=0,&#8221;New&#8221;,D3\/B3)<\/em> to make the word <em>New<\/em> appear as the % Change for any item with no Year 1 Sales.<br \/>\nIf you want to display a number, leave out the quotation marks and put the number after the =, as in =IF(B3=0,0,D3\/B3) to have a zero displayed when Year 1 Sales=0.<br \/>\nTo display the contents of another cell when Year 1 Sales are 0, enter the cell reference after the = in your formula, as in <em>=IF(B3=0,G10,D3\/B3)<\/em>. Don&#8217;t use quotation marks or Excel will display the cell reference (G10) instead of the contents of that cell.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nobody likes to see #DIV\/0!, Excel&#8217;s divide by zero error, on their spreadsheet.  But there is no option to suppress it and sometimes your data makes the error inevitable.  Fortunately you can use the IF function to hide or replace the divide by zero error message.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/707"}],"collection":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=707"}],"version-history":[{"count":4,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/707\/revisions"}],"predecessor-version":[{"id":2404,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/707\/revisions\/2404"}],"wp:attachment":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}