Microsoft Excel

Visual Basic Tools

Visual Basic is a powerful development environment. Although this tutorial cannot offer a complete course on VBA, if you are new to VBA, you will want to take advantage of these important tools in VBA:

  • As you begin to type code, Excel may offer a drop-down with valid choices. This feature, known as AutoComplete, allows you to type code faster and eliminate typing mistakes.

  • For assistance on any keyword, put the cursor in the keyword and press the F1 key. You might need your installation CDs because the VBA help file is not in the default install.

  • Excel checks each line of code as you finish it. Lines in error will appear in red. Comments will appear in green. You can add a comment by typing a single apostrophe. Use lots of comments so you can remember what each section of code is doing.

  • Despite the aforementioned error checking, Excel may still encounter an error at runtime. If this happens, click the Debug button. The line that caused the error will be highlighted in yellow. Hover your cursor over any variable to see the current value of the variable.

  • When you are in Debug mode, use the Debug menu to step line by line through code. You can toggle back and forth between Excel and VBA to see the effect of running a line of code on the worksheet.

  • Other great debugging tools are breakpoints, the Watch window, the Object Browser, and the Immediate window. Read about these in the Excel help menu.

by BrainBellupdated