Excel 2010 Bible

(National Geographic (Little) Kids) #1

823


CHAPTER


Creating Custom


Worksheet Functions


IN THIS CHAPTER


Overview of VBA functions

About function procedures

Function procedure arguments

Debugging custom functions

Pasting custom functions

A


s mentioned in the preceding chapter, you can create two types of
VBA procedures: Sub procedures and Function procedures. This
chapter focuses on Function procedures.

Overview of VBA Functions


Function procedures that you write in VBA are quite versatile. You can use
these functions in two situations:

l You can call the function from a different VBA procedure.

l (^) You can use the function in formulas that you create in a worksheet.
This chapter focuses on creating functions for use in your formulas.
Excel includes hundreds of predefined worksheet functions. With so many
from which to choose, you may be curious as to why anyone would need to
develop additional functions. The main reason is that creating a custom
function can greatly simplify your formulas by making them shorter, and
shorter formulas are more readable and easier to work with. For example,
you can often replace a complex formula with a single function. Another rea-
son is that you can write functions to perform operations that would other-
wise be impossible.
Note
This chapter assumes that you’re familiar with entering and editing VBA code
in the Visual Basic Editor (VB Editor). See Chapter 39 for an overview of the
VB Editor. n

Free download pdf