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 631<br />

In this case, the problem is the use of the And operator instead of the concatenation operator<br />

(&). The correct statement is as follows:<br />

REVERSETEXT = REVERSETEXT & Mid(text, i, 1)<br />

When you click the Debug button, the procedure is still running — it’s just halted and is<br />

in break mode. After you make the correction, press F5 to continue execution, press F8<br />

to continue execution on a line-by-line basis, or click the Reset button (in the Standard<br />

toolbar) to halt execution.<br />

Setting a breakpoint in the function<br />

Another debugging technique is to set a breakpoint in your code. Execution pauses when VBA<br />

encounters a breakpoint. You can then use the Immediate window to check the values of your<br />

variables, or you can use F8 to step through your code line by line.<br />

To set a breakpoint, move the cursor to the statement at which you want to pause execution and<br />

choose Debug➜Toggle Breakpoint. Alternatively, you can press F9, or you can click the vertical<br />

bar to the left of the code window. Any of these actions highlights the statement to remind you<br />

that a breakpoint is in effect (you also see a dot in the code window margin). You can set any<br />

number of breakpoints in your code. To remove a breakpoint, move the cursor to the statement<br />

and press F9. Figure 23-10 shows a Function procedure that contains a breakpoint.<br />

Figure 23-10: The highlighted statement contains a breakpoint.

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

Saved successfully!

Ooh no, something went wrong!