ABSTRACT

In general, a module contains two types of procedures: sub procedures and function procedures. This chapter introduces how to create function procedures. It also introduces event handlers and methods for reading and writing files. After studying the chapter, readers will be able to create functions, create event handlers, and read and write text files. A function allows us to return some result to the caller of the function. An event handler enables us to execute some Visual Basic for Applications (VBA) code automatically. The event-handler is a sub procedure with one argument. The file Input-Output (IO) functions allows us to import and export data from text files in a controlled way. A VBA sub procedure can be executed automatically when a particular event occurs. The chapter presents some Excel® event types and where to place event-handler VBA code.