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.

on_the_web.eps

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”)

Get Excel 2013 Formulas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.