O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Excel VBA Programming For Dummies, 5th Edition

Book Description

Take your Excel programming skills to the next level

To take Excel to the next level, you need to understand and implement the power of Visual Basic for Applications (VBA). Excel VBA Programming For Dummies introduces you to a wide array of new Excel options, beginning with the most important tools and operations for the Visual Basic Editor.

Inside, you’ll find an overview of the essential elements and concepts for programming with Excel. In no time, you’ll discover techniques for handling errors and exterminating bugs, working with range objects and controlling program flow, and much more. With friendly advice on the easiest ways to develop custom dialog boxes, toolbars, and menus, readers will be creating Excel applications custom fit to their unique needs!

  • Fully updated for the new Excel 2019
  • Step-by-step instructions for creating VBA macros to maximize productivity
  • Guidance on customizing your applications so they work the way you want
  • All sample programs, VBA code, and worksheets are available at dummies.com

Beginning VBA programmers rejoice! This easy-to-follow book makes it easier than ever to excel at Excel VBA!

Table of Contents

  1. Cover
  2. Introduction
    1. About This Book
    2. Obligatory Typographical Conventions Section
    3. Check Your Security Settings
    4. Foolish Assumptions
    5. Icons Used in This Book
    6. Sample Files Online
    7. Where to Go from Here
  3. Part 1: Getting Started with Excel VBA Programming
    1. Chapter 1: What Is VBA?
      1. Okay, So What Is VBA?
      2. What Can You Do with VBA?
      3. Advantages and Disadvantages of VBA
      4. VBA in a Nutshell
      5. Excel Compatibility
    2. Chapter 2: Jumping Right In
      1. First Things First
      2. What You’ll Be Doing
      3. Taking the First Steps
      4. Recording the Macro
      5. Testing the Macro
      6. Examining the Macro
      7. Modifying the Macro
      8. Saving Workbooks That Contain Macros
      9. Understanding Macro Security
      10. Revealing More about the NameAndTime Macro
  4. Part 2: How VBA Works with Excel
    1. Chapter 3: Working in the Visual Basic Editor
      1. What Is the Visual Basic Editor?
      2. Working with the Project Window
      3. Working with a Code Window
      4. Customizing the VBA Environment
    2. Chapter 4: Introducing the Excel Object Model
      1. Excel Is an Object?
      2. Climbing Down the Object Hierarchy
      3. Wrapping Your Mind around Collections
      4. Referring to Objects
      5. Diving into Object Properties and Methods
      6. Finding Out More
    3. Chapter 5: VBA Sub and Function Procedures
      1. Understanding Subs versus Functions
      2. Naming Subs and Functions
    4. Chapter 6: Using the Excel Macro Recorder
      1. Recording Basics
      2. Preparing to Record
      3. Relative or Absolute?
      4. What Gets Recorded?
      5. Recording Options
      6. Is This Thing Efficient?
  5. Part 3: Programming Concepts
    1. Chapter 7: Essential VBA Language Elements
      1. Using Comments in Your VBA Code
      2. Using Variables, Constants, and Data Types
      3. Using Assignment Statements
      4. Working with Arrays
      5. Using Labels
    2. Chapter 8: Working with Range Objects
      1. A Quick Review
      2. Other Ways to Refer to a Range
      3. Some Useful Range Object Properties
      4. Some Useful Range Object Methods
    3. Chapter 9: Using VBA and Worksheet Functions
      1. What Is a Function?
      2. Using Built-In VBA Functions
      3. Using Worksheet Functions in VBA
      4. Using Custom Functions
    4. Chapter 10: Controlling Program Flow and Making Decisions
      1. Going with the Flow, Dude
      2. The GoTo Statement
      3. Decisions, Decisions
      4. Knocking Your Code for a Loop
      5. Using For Each-Next Loops with Collections
    5. Chapter 11: Automatic Procedures and Events
      1. Preparing for the Big Event
      2. Where Does the VBA Code Go?
      3. Writing an Event-Handler Procedure
      4. Introductory Examples
      5. Examples of Activation Events
      6. Other Worksheet-Related Events
      7. Events Not Associated with Objects
    6. Chapter 12: Error-Handling Techniques
      1. Types of Errors
      2. An Erroneous Example
      3. Handling Errors Another Way
      4. Handling Errors: The Details
      5. An Intentional Error
    7. Chapter 13: Bug Extermination Techniques
      1. Species of Bugs
      2. Identifying Bugs
      3. Debugging Techniques
      4. About the Debugger
      5. Bug Reduction Tips
    8. Chapter 14: VBA Programming Examples
      1. Working with Ranges
      2. Changing Excel Settings
      3. Working with Charts
      4. VBA Speed Tips
  6. Part 4: Communicating with Your Users
    1. Chapter 15: Simple Dialog Boxes
      1. UserForm Alternatives
      2. The MsgBox Function
      3. The InputBox Function
      4. The GetOpenFilename Method
      5. The GetSaveAsFilename Method
      6. Getting a Folder Name
      7. Displaying Excel’s Built-in Dialog Boxes
    2. Chapter 16: UserForm Basics
      1. Knowing When to Use a UserForm
      2. Creating UserForms: An Overview
      3. Working with UserForms
      4. A UserForm Example
    3. Chapter 17: Using UserForm Controls
      1. Getting Started with Dialog Box Controls
      2. Dialog Box Controls: The Details
      3. Working with Dialog Box Controls
      4. Dialog Box Aesthetics
    4. Chapter 18: UserForm Techniques and Tricks
      1. Using Dialog Boxes
      2. A UserForm Example
      3. A ListBox Example
      4. Selecting a Range
      5. Using Multiple Sets of OptionButtons
      6. Using a SpinButton and a TextBox
      7. Using a UserForm as a Progress Indicator
      8. Creating a Modeless Tabbed Dialog Box
      9. Displaying a Chart in a UserForm
      10. A Dialog Box Checklist
    5. Chapter 19: Accessing Your Macros through the User Interface
      1. Customizing the Ribbon
      2. Customizing Shortcut Menus
  7. Part 5: Putting It All Together
    1. Chapter 20: Creating Worksheet Functions — and Living to Tell about It
      1. Why Create Custom Functions?
      2. Understanding VBA Function Basics
      3. Writing Functions
      4. Working with Function Arguments
      5. Introducing Wrapper Functions
      6. Working with Functions That Return an Array
      7. Using the Insert Function Dialog Box
    2. Chapter 21: Creating Excel Add-Ins
      1. Okay … So What’s an Add-In?
      2. Why Create Add-Ins?
      3. Working with Add-Ins
      4. Understanding Add-In Basics
      5. Looking at an Add-In Example
  8. Part 6: The Part of Tens
    1. Chapter 22: Ten Handy Visual Basic Editor Tips
      1. Applying Block Comments
      2. Copying Multiple Lines of Code at Once
      3. Jumping between Modules and Procedures
      4. Teleporting to Your Functions
      5. Staying in the Right Procedure
      6. Stepping Through Your Code
      7. Stepping to a Specific Line in Your Code
      8. Stopping Your Code at a Predefined Point
      9. Seeing the Beginning and End of Variable Values
      10. Turning Off Auto Syntax Check
    2. Chapter 23: Resources for VBA Help
      1. Letting Excel Write Code for You
      2. Pilfering Code from the Internet
      3. Leveraging User Forums
      4. Visiting Expert Blogs
      5. Mining YouTube for Video Training
      6. Attending Live and Online Training Classes
      7. Learning from the Microsoft Office Dev Center
      8. Dissecting the Other Excel Files in Your Organization
      9. Asking Your Local Excel Guru
    3. Chapter 24: Ten VBA Do’s and Don’ts
      1. Do Declare All Variables
      2. Don’t Confuse Passwords with Security
      3. Do Clean Up Your Code
      4. Don’t Put Everything in One Procedure
      5. Do Consider Other Software
      6. Don’t Assume That Everyone Enables Macros
      7. Do Get in the Habit of Experimenting
      8. Don’t Assume That Your Code Will Work with Other Excel Versions
      9. Do Keep Your Users in Mind
      10. Don’t Forget About Backups
  9. Index
  10. About the Author
  11. Advertisement Page
  12. Connect with Dummies
  13. End User License Agreement