home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / pbaseiv.zip / P4SPR007.TIP < prev    next >
Text File  |  1991-12-16  |  2KB  |  48 lines

  1. In a 1-2-3 worksheet, I have to calculate the difference
  2. between two numbers as a percentage of the second one. I
  3. used to do this with the formula (B12-C12)/C12. But if cell
  4. C12 was empty, which it was if I hadn't yet typed a value,
  5. the formula produced an ERR value. That didn't suit me; if
  6. C12 was blank, I wanted the cell with the formula to be
  7. blank as well.
  8.  
  9. To solve the problem, I replaced the formula with a new one,
  10. @IF(@ISERR((B12-C12)/C12)," ",(B12-C12)/C12), which leaves
  11. the formula cell blank if C12 is empty. The @ISERR function
  12. evaluates the original formula and returns a true value if
  13. the result is ERR. @IF puts a blank in the cell if @ISERR is
  14. true or does the calculation again if @ISERR is false.
  15.  
  16. Robert Siegel
  17. Vienna, Virginia
  18.  
  19. Editor's note: You can make this trick even easier by
  20. placing the formula that might produce an error in a cell
  21. that's outside the range you see and print. For instance, if
  22. you put the formula that does the calculation in, say, AK12,
  23. you can use the formula @IF(@ISERR(AK12)," ",AK12) . This
  24. approach has two advantages: First, the math isn't done
  25. twice; second, you can edit the formula once--rather than
  26. twice--if it needs to be changed.
  27.  
  28. Postscript: Several readers responded to this tip by
  29. claiming that the formula @IF(C12,(B11-C12)/C12,"") works
  30. just as well as the more complicated one we printed. This is
  31. only partially true. It catches divisions by zero, the most
  32. likely error -- but it won't catch other errors, such as
  33. overflows and underflows.
  34.  
  35. Siegel's method is much more versatile. Since the
  36. @IFERR function can catch any condition that generates an
  37. ERR, it will handle formulas involving logarithms,
  38. exponentials, trigonometric functions, and date
  39. functions--in which errors are harder to predict. Thus,
  40. unless you're sure you can catch every error condition, it's
  41. best to play safe and test for ERR instead.
  42.  
  43. Title: To ERR Is Electronic
  44. Category: SPR
  45. Issue date: Aug 1991
  46. Editor: Brett Glass
  47. Supplementary files: NONE
  48.