Tips on How to Learn Visual Basic

The following are suggestions for getting the most from the time you spend learning Visual Basic.

Learn Microsoft Excel first

The more you know about Microsoft Excel, the better prepared you'll be to venture into Visual Basic. Most macros perform a sequence of actions in Microsoft Excel, and most instructions in a macro are equivalent to commands or actions in Microsoft Excel. Consequently, working with Visual Basic is a little like working with Microsoft Excel without a user interface; instead of commands and dialog boxes, you use Visual Basic instructions. The statements and functions you use to write instructions are much easier to understand if you're familiar with the features they represent in Microsoft Excel.

Also, if you know Microsoft Excel well, you can better answer the question you're most likely to ask when writing a macro: "What's the best way to do this?" People have been known to write long macros for tasks that could have been handled by a single Microsoft Excel command.

Learn what you need, when you need it

Learn what you need for the task at hand. Visual Basic can seem overwhelming at first, particularly if you haven't had experience with a macro programming language. A great way to learn the language is to investigate how to implement a particular macro idea you have. As you gain experience writing different types of macros, you'll cover a lot of ground.

Use the macro recorder

The macro recorder can record the Visual Basic instruction for virtually every action you take in Microsoft Excel. You can use the macro recorder to see how actions in Microsoft Excel translate into Visual Basic instructions, and vice versa. Also, you'll find that recording part of a macro is often faster and easier than writing out the instructions.

Use Visual Basic Help

Help is a powerful tool for learning Visual Basic. In a Visual Basic module, you can type a Visual Basic keyword and — with the insertion point somewhere in the keyword — press F1 to immediately display Visual Basic Help for that keyword. The Visual Basic Help topic for most keywords includes an example you can copy and paste into your macro. For more information, see "Using Online Help" later in this introduction.