| Customizing "division by 0" error messages - Excel | | Print | |
Working in a complex worksheet, you may have encountered that annoying "#DIV/0!" error when the divisor of your formula is a zero. Using the built-in IF function, you can create your own message for display when you divide by zero:
=IF (DIVISOR = 0,"Your Text", DIVIDED/DIVISOR)
The IF function evaluates the first parameter (DIVISOR = 0). If it's TRUE, it places the second parameter ("Your Text") in the cell. If it's FALSE, the function places the third parameter (DIVIDED/DIVISOR) in the cell.
This helps you control the message that's displayed when your formula produces a zero value that is then used to divide another value.
Debugging your code
A great way to find errors in your code is to step through it one line at a time. The Step Into button on the Debug toolbar in the VBA Editor lets you do this.
To start your macro, just click Step Into on the toolbar. The VBA Editor will work through each statement. This allows you to take advantage of some of the other debug tools, such as the Locals window and the Watchwindow.
When stepping through your code, you can use the Step Out command to run the remaining code as normal. So even if you stepped through half the macro one statement at a time, you can then run the last half normally by clicking Step Out.
| Users' Comments (0) |
|
No comment posted






