Summary

In this chapter, you have seen those elements of the VBA language that enable you to write useful and efficient procedures. You have seen how to add interaction to macros with the MsgBox and InputBox functions, how to use variables to store information, and how to get help with VBA keywords.

You have seen how to declare variables and define their type, and the effect on variable scope and lifetime of different declaration techniques. In addition, you used the block If and Select Case structures to perform tests and carry out alternative calculations, and Do...Loop and For...Next loops that allow you to efficiently repeat similar calculations. You have seen how arrays can be used, particularly with looping procedures. Moreover, you learned how to use On Error statements to trap errors.

When writing VBA code for Excel, the easiest way to get started is to use the macro recorder. You can then modify that code, using the VBE, to better suit your purposes and to operate efficiently. Using the Object Browser, Help screens, and the reference section of this book, you can discover objects, methods, properties, and events that can't be found with the macro recorder. Using the coding structures provided by VBA, you can efficiently handle large amounts of data and automate tedious processes.

You now have the knowledge required to move on to the next chapter, where you will find a rich set of practical examples showing you how to work with key Excel objects. You will discover how to create your own user interface, setting up your own Ribbon buttons and dialog boxes, and embedding controls in your worksheets to enable yourself and others to work more productively.

0 0

Post a comment