Book Image

VBA Automation for Excel 2019 Cookbook

By : Mike Van Niekerk
Book Image

VBA Automation for Excel 2019 Cookbook

By: Mike Van Niekerk

Overview of this book

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.
Table of Contents (20 chapters)

Preface

Visual Basic for Applications (VBA) has been around for decades, and was upgraded in 2010 with the introduction of VBA 7 in Microsoft Office applications. Millions of users worldwide use VBA daily, making it indispensable for streamlining work within the Office Suite.

It is probably one of the easiest coding languages to learn, and unique in the sense that it is associated with specific applications. Where other coding languages can be used to create standalone programs, VBA will function only within the MS Office environment.

VBA's main purpose is to automate tasks in Microsoft Office products, and its most outstanding feature is its simplicity. Even if you know nothing about programming, you will see results within the first day.

Starting with the macro recorder, you can create your first code by clicking a record button, and the recorder will write code for every single step you execute. Experienced coders can write more effective code, yet it enables complete novices to automate lengthy and time-consuming processes. With this recorded code as the basis, you can become adventurous by making small changes, teaching yourself as you go along.

Another useful feature is that VBA can control one application from another. You can, for example, automatically create a report in MS Word or PowerPoint, from existing Excel data.

Companies other than Microsoft also use VBA to automate some tasks. These include ArcGIS, AutoCAD, CorelDraw, LibreOffice, SolidWorks, and WordPerfect.

This book is designed to teach you the language, first on an elementary level, and later moving to more advanced terrain. We start with recording a macro, then proceed to writing your own Sub procedures. Next, we teach you the object model and language elements, program flow, error handling, user forms for capturing data, and eventually creating custom functions.

Each chapter contains code samples to explain the principles taught in each recipe. As an added bonus, there are action videos to clarify each working sample.