Microsoft Office Tutorials and References
In Depth Information
Weapons of Mass Debugging
Stepping through Code
On the Debug toolbar, three icons, named Step
Into, Step Over, and Step Out, are related to a
process known as stepping through code. There
are times when you’ll want to examine each
statement in your macro if you suspect a bug
is somewhere in your code but you’re not sure
where. Even large macros can run quickly, so it’s
difficult, and often impossible, to isolate the
specific command that is not executing the way you
would have planned. Stepping through your VBA
statements allows you to execute one or more
lines of code, at your own pace, to see for
yourself what every VBA statement is really doing.
figurE 17-7
Suppose you oversee a region of 10 hardware stores, and you receive a table of each store’s quarterly
sales activity. Your table is in a raw form, downloaded into Excel from your company’s database,
resembling Figure 17-7.
You have a macro such as the one pictured in Figure 17-8 that formats the table and sorts the Net
Income column in descending order so you can quickly list the most profitable stores. When you run
the macro, you do not get a compile or runtime error, but something still doesn’t look right when
the macro completes its full execution, as shown in Figure 17-9.
figurE 17-8
Search JabSto ::

Custom Search