18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Creating Custom Worksheet<br />

Functions<br />

As mentioned in the preceding chapter, you can create two types of VBA<br />

procedures: Sub procedures and Function procedures. This chapter<br />

focuses on Function procedures.<br />

Overview of VBA Functions<br />

Function procedures that you write in VBA are quite versatile. You can use these<br />

functions in two situations:<br />

n You can call the function from a different VBA procedure.<br />

n You can use the function in formulas that you create in a worksheet.<br />

This chapter focuses on creating functions for use in your formulas.<br />

Excel contains hundreds of predefined worksheet functions. With so many from<br />

which to choose, you may be curious as to why anyone would need to develop<br />

additional functions. The main reason is that creating a custom function can<br />

greatly simplify your formulas by making them shorter, and shorter formulas are<br />

more readable and easier to work with. For example, you can often replace a<br />

complex formula with a single function. Another reason is that you can write<br />

functions to perform operations that would otherwise be impossible.<br />

This chapter assumes that you’re familiar with entering and<br />

NOTE<br />

editing VBA code in the Visual Basic Editor (VB Editor). Refer<br />

to Chapter 39 for an overview of the VB Editor.<br />

IN THIS CHAPTER<br />

Overview of VBA functions<br />

About function procedures<br />

Function procedure arguments<br />

Debugging custom functionsy<br />

Pasting custom functions<br />

703

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!