• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

What Is a Macro?

A macro is a VBA procedure. A procedure is a group of VBA statements that either performs a specific task or returns a result. You can create two types of procedures in Excel: subroutines and functions. Subroutines are procedures that perform a specific task. The code for subroutines begins with the word Sub and ends with the words End Sub (see Listing 31.1 for an example). A macro is a subroutine-type procedure. For the purposes of this chapter, macro and subroutine are interchangeable terms.

Code Listing 31.1. This Macro Selects and Prints the Current Region

Sub PrintRegion()
    Selection.CurrentRegion.Select
    Selection.PrintOut Copies:=1, Collate:=True
End Sub


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint