• 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 perform a specific task or return a result. There are two types of procedures that you can create in Excel. 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 29.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 29.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