11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 23: Function Procedure Basics 629<br />

To help identify the source of the runtime error, insert the following Sub procedure:<br />

Sub Test()<br />

x = REVERSETEXT(“Hello”)<br />

MsgBox x<br />

End Sub<br />

This Sub procedure simply calls the REVERSETEXT function and assigns the result to a variable<br />

named x. The MsgBox statement displays the result.<br />

You can execute the Sub procedure directly from the VB Editor. Simply move the cursor anywhere<br />

within the procedure and choose Run➜Run Sub/UserForm (or just press F5). When you<br />

execute the Test procedure, you see the error message that is shown in Figure 23-8.<br />

Figure 23-8: A runtime error identified by VBA.<br />

Click the Debug button, and the VB Editor highlights the statement causing the problem (see<br />

Figure 23-9). The error message does not tell you how to correct the error, but it does narrow<br />

your choices. After you’ve identified the statement that’s causing the error, you can examine it<br />

more closely, or you can use the Immediate window (see the sidebar, “Using the Immediate window”)<br />

to help locate the exact problem.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!