Chapter 25: VBA Programming Concepts
In This Chapter
• Introducing an example Function procedure
• Using comments in your code
• Understanding VBA's language elements, including variables, data types, and constants
• Using assignment expressions in your code
• Declaring arrays and multidimensional arrays
• Using the built-in VBA functions
• Controlling the execution of your Function procedures
• Using ranges in your code
This chapter discusses some of the key language elements and programming concepts in VBA. If you've used other programming languages, much of this information may sound familiar. VBA has a few unique wrinkles, however, so even experienced programmers may find some new information.
This chapter does not even come close to being a comprehensive guide to VBA. Motivated readers can consult the Help system and make use of Internet resources or other books for additional information.
Many of the code examples in this chapter are available at this book's website. The file is named function examples.xlsm.
An Introductory Example Function Procedure
To get the ball rolling, I'll begin with an example Function procedure. This function, named REMOVESPACES, accepts a single argument and returns that argument without any spaces. For example, the following formula uses the REMOVESPACES function and returns ThisIsATest.
=REMOVESPACES(“This Is A Test”)
To create this function, ...