0%

Book Description

A comprehensive guide to gaining a 360-degree overview of the VBA programming language and learning how to build your own programs for automating routine tasks

Key Features

  • Extend the capabilities of Excel and other Office applications with the help of Microsoft VBA
  • Take your Excel programming skills to the next level by creating custom applications with dialogue boxes and the range object
  • Automate repetitive and monotonous office work with VBA Excel programming

Book Description

Visual Basic for Applications (VBA) is a programming language developed by Microsoft to automate tasks in MS Office applications. This book will help you to focus on the essential aspects of your role by automating mundane tasks in Excel and other Office applications. With comprehensive coverage of VBA delivered in the form of practice problems and bite-sized recipes, this book will help you to hit the ground running.

Unlike most books that assume prior programming experience, this book starts with the fundamentals and gradually progresses to solving bigger problems.

You'll start by becoming familiar with VBA so that you can start recording macros right away. With this foundation in place, you'll advance to using the full capabilities of the language as you apply loops, functions, and custom dialog boxes to design your own automation programs. You'll also get to grips with embedded macros and other advanced tools to enhance productivity and explore topics relating to app performance and security. Throughout this VBA book, you'll cover multiple practice projects in Excel, Word, and PowerPoint while exploring tips and best practices to hone your skills.

By the end of this book, you'll have developed the skills you need to use VBA to create your own programs that control MS Office applications.

What you will learn

  • Understand the VBA programming language's role in the context of the MS Office suite
  • Discover various aspects of VBA programming such as its terminology, syntax, procedures, functions, and forms
  • Investigate the elements, features, and characteristics of the VBA Editor to write and edit custom scripts
  • Automate Excel sheets with the help of ranges
  • Explore error handling and debugging techniques to catch bugs in your programs
  • Create and use custom dialog boxes to collect data from users
  • Customize and extend Office apps such as Excel, PowerPoint, and Word

Who this book is for

This book is for experienced Excel users, business analysts, finance professionals, and business users looking to boost their productivity by learning VBA programming to automate repetitive, tedious, or complex tasks. No prior programming experience is required to get started with this book.

Table of Contents

  1. VBA Automation for Excel 2019 Cookbook
  2. Why subscribe?
  3. Contributors
  4. About the author
  5. About the reviewer
  6. Packt is searching for authors like you
  7. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
    4. Code in Action
    5. Download the color images
    6. Conventions used
    7. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    8. Get in touch
    9. Reviews
  8. Chapter 1: Getting Started with VBA
    1. Technical requirements
    2. Investigating VBA code
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    3. Recording a macro
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    4. Testing the macro
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    5. Using the VBA Editor
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    6. Editing the code by changing cell references
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    7. Saving the file with an embedded macro
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    8. Using the Trust Center for macro security
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    9. Creating a customized ribbon
      1. Getting ready
      2. How to do it…
  9. Chapter 2: Working with the VBA Editor
    1. Technical requirements
    2. Identifying, activating, and closing components in the VBA Editor
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Creating a module for storing a Sub procedure
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Creating a basic procedure in the code window of the Editor
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Creating VBA code in the code window in three different ways
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    6. Customizing the Editor tab to suit your preferences
      1. Getting ready
      2. How to do it…
      3. How it works…
  10. Chapter 3: The VBA Object Model
    1. Technical requirements
    2. Understanding and identifying objects in VBA
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Objects as a collection, and changing the attributes of the entire collection
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Modifying object properties
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    5. Associating methods with objects
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Using events to activate objects
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Using the Object Browser in the VBA Editor
      1. Getting ready
      2. How to do it…
      3. How it works…
  11. Chapter 4: Working with Procedures
    1. Technical requirements
    2. Creating Sub and Function procedures
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    3. Executing Sub procedures directly
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Executing Sub procedures from the Macro dialog box
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Executing Sub procedures using buttons
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    6. Executing Sub procedures using a shortcut key
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Executing Function procedures using a worksheet formula
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Executing Function procedures by calling from a Sub procedure
      1. Getting ready
      2. How to do it…
      3. How it works…
  12. Chapter 5: Next Level Recording
    1. Technical requirements
    2. Setting the macro recorder for absolute or relative reference
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Recording options
      1. Getting ready
      2. How to do it…
      3. How it works…
  13. Chapter 6: VBA Language Elements
    1. Technical requirements
    2. Adding comments
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Declaring variables
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Declaring constants
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    5. Working with data types in variables and constants
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Scoping variables
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Declaring arrays
      1. Getting ready
      2. How to do it…
      3. How it works…
  14. Chapter 7: Working with Ranges
    1. Technical requirements
    2. Referring to ranges
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Using the Range object properties
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Adding the Range object's methods
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Making ranges work
      1. Getting ready
      2. How to do it…
      3. How it works…
  15. Chapter 8: Using Functions
    1. Technical requirements
    2. Using built-in VBA functions
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Using worksheet functions
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Creating custom functions
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
  16. Chapter 9: Implementing Program Flow
    1. Technical requirements
    2. Exploring program flow
    3. Changing the flow using the GoTo statement
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Using If and If-Then structures to make decisions
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    5. Using the Select Case structure
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Using loops
      1. Getting ready
      2. How to do it…
      3. How it works…
  17. Chapter 10: Implementing Automation
    1. Technical requirements
    2. Writing event handler procedures
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    3. Discovering events
    4. Creating workbook-related events
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Creating worksheet-related events
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Creating non-object events
      1. Getting ready
      2. How to do it…
      3. How it works…
  18. Chapter 11: Handling Errors
    1. Technical requirements
    2. Handling different types of errors
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Correcting a runtime error
      1. Getting ready
      2. How to do it…
      3. How it works
    4. Testing to find errors
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Using the On Error statement
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Resuming after an error
      1. Getting ready
      2. How to do it…
      3. How it works…
  19. Chapter 12: Debugging
    1. Technical requirements
    2. Exploring various bugs
    3. Debugging techniques
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Using the debugger in Excel
      1. Setting breakpoints
      2. Using the Watch window
  20. Chapter 13: Creating and Modifying Dialog Boxes
    1. Technical requirements
    2. Using the MsgBox function
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Using the InputBox function
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Using the Application.InputBox method
      1. Getting ready
      2. How to do it…
      3. How it works…
  21. Chapter 14: Creating UserForms
    1. Technical requirements
    2. Inserting the form
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Changing properties
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Adding controls
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    5. Using Frames
      1. Getting ready
      2. How to do it…
      3. There's more…
  22. Chapter 15: UserForm Controls
    1. Technical requirements
    2. Assigning controls
      1. Getting ready
      2. How to do it…
      3. How it works
    3. Unloading a form
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Loading the form
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Using the Combo Box control
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Using the SpinButton control
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    7. Setting the tab order
      1. Getting ready
      2. How to do it…
      3. How it works
  23. Chapter 16: Creating Custom Functions
    1. Technical requirements
    2. Writing functions
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Calling functions
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Adding function arguments
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    5. Displaying function and argument descriptions
      1. Getting ready
      2. How to do it…
  24. Chapter 17: Creating Word Documents with Excel VBA
    1. Technical requirements
    2. Creating a new instance of Word
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Writing and formatting text
      1. Getting ready
      2. How to do it…
    4. Copying data into Word
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    5. Using templates and bookmarks
      1. Getting ready
      2. How to do it…
      3. See also
  25. Chapter 18: Working with PowerPoint in Excel VBA
    1. Technical requirements
    2. Creating a new instance of PowerPoint
      1. Getting ready
      2. How to do it…
    3. Creating presentations and slides
      1. Getting ready
      2. How to do it…
    4. Adding text to textboxes
      1. Getting ready
      2. How to do it…
    5. Copying Excel content into PowerPoint
      1. Getting ready
      2. How to do it…
      3. There's more…
  26. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.138.141.202