O'Reilly logo

Mastering VBA for Microsoft Office 2016 by Richard Mansfield

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10Creating Your Own Functions

In Chapter 10, “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 include 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, in VBA functions differ from subs. The primary difference is that functions interact more with other procedures. Functions accept arguments (incoming data) from the procedure that calls them, and they return a value ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required