images

Chapter 10

Creating Your Own Functions

In Chapter 9, “Using Built-in Functions,” you learned how to use VBA's built-in functions. In this chapter, you'll learn how to create your own functions. You create a function the same way you create a subprocedure: by typing in the Code window. (You can't record a function in Excel and Word—the applications that provide a Macro Recorder. Instead, you have to write functions yourself because the Recorder creates only subprocedures.)

It's important to recall that, although both are procedures, functions differ from subs. The primary difference is that functions interact more with other procedures: They accept ...

Get Mastering VBA for Microsoft Office 2013 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.