| VBA - The Excel Working Partner | |||||||||||||||||||||||||
| Using VBA with Microsoft Excel | |||||||||||||||||||||||||
|
Let's see what some of them are ... As mentioned in the Introduction, this tutorial is based on Excel 2000 and VBA 6 because that's what most of our readers are using. |
|||||||||||||||||||||||||
Every Office application (in fact, every VBA hosting application) saves the VBA program in a slightly different way. The actual VBA program is normally saved as part of the hosting application's documents (this was demonstrated in the first segment by displaying the text contents of a VBA program inside a Word document). To discover how Excel saves a VBA program, let's start with the same technique that we learned in the previous two segments: Tools > Macro > Record New Macro ... . The resulting dialog has slightly different choices now, however. Excel gives you the choice of saving your VBA program in:
The last two seem reasonably obvious. Excel's primary document is the Workbook and you have a choice of saving your program in the one you have open or a new one. The first option, Personal Macro Workbook, is a little more interesting. When you click OK, you see that there's a new button on the Record New Macro Stop dialog. (Like most of Excel, this dialog can be customized so it's possible that your installation might be different.) In the code below, notice that the cell we're referencing is addressed using the absolute position "A2".
If you click this button the Recorder will give you relative positioning (statements like ActiveCell.Offset(6, 3). ...). Next page > Record a Code Sample For Yourself > Page 1, 2, 3, 4 |
|||||||||||||||||||||||||

Excel is the Office application that is most frequently automated using VBA. In fact, Excel is where it all began. VBA was first implemented in Excel 5 in 1993. This probably happened for the same reason that the mainline accounting functions were the first to be automated using computers in the 1950's. Numbers and computers just go together. So there are a lot of really useful things you can do with Excel and VBA!

