Who is this book for?
This book is for you if you’re an intermediate to advanced Excel user and you want to learn how to create VBA procedures to automate tasks in Excel. Maybe, you also want to be able to create your own user-defined functions to perform certain calculations for which there are no dedicated built-in Excel functions.
Unlike other programming books that you might have seen, this book doesn’t
assume you have any programming experience. You don’t need to have even written any programming code in your life because we’ll start from the basics.
As the title implies, this is a book about using macros and VBA to extend the power of Excel. It’s not a general-purpose Excel book. To stay focused on macros and VBA, I’m assuming you’re already competent with Excel. If you need a general-purpose Excel book, you can check out my Excel 2019 Basics or Excel 2019 Advanced Topics books.
Excel 2019 Macros and VBA is not an in-depth book on the VBA programming language. It’s a vast language and there is only so much a modest-sized book can cover. So, the focus is on the essentials you need to get you started in creating VBA solutions, and to provide solid foundations on which you can build your experience through use. If you're already experienced in VBA, then this book is not for you.
How to Use This Book
Excel 2019 Macros and VBA can be used as a step-by-step training guide as well as a reference manual that you come back to from time to time. If you’re completely new to Excel programming, then it is recommended that you read the chapters in sequential order. This is because some topics you’ll encounter in later chapters would be based on topics covered in earlier chapters.
If you’re already experienced in recording Excel macros, then you can skip to the chapters that cover VBA programming.
Assumptions
The software and hardware assumptions made when writing this book is that you already have Excel installed on your computer (Excel 2013, Excel 2016, or Excel 2019) and that you’re working on a Windows 10 computer.
If you’re running Excel on a Mac, then simply substitute any Windows keyboard commands mentioned in the book for the Mac equivalent.
Source Code
All code examples in the book have been included in a downloadable text file. To use the code, you’ll need to copy and paste them into your project in the Visual Basic Editor. You can download the file with the following weblink:
https://ngdigital.s3.amazonaws.com/Excel2019MacrosVBA.zip
Note : The files have been zipped into one download. Windows 10 comes with the functionality to unzip files but if your OS does not have this functionality, you’ll need to get a piece of software like WinZip or WinRAR to unzip the file.
What’s the Difference Between Macros and VBA?
An Excel macro is a recorded set of instructions stored in Visual Basic for Applications (VBA) code. The VBA programming language was developed by Microsoft as a tool to control and automate Microsoft Office applications.
The difference between Excel macros and VBA programming can be fuzzy because macros are stored as VBA procedures, but not all VBA procedures are macros. For example, you can create Function procedures in VBA that are not used like macros.
You don’t necessarily need to have VBA programming experience to record and run simple Excel macros. But to write the macros directly in VBA, or to edit a recorded macro, you need to be familiar with the VBA programming language. On some occasions, the process of creating macros will involve editing the generated code to change how the macro behaves or to fix errors. VBA gives you more flexibility and power to control Excel than the macro recorder affords.
Another benefit of VBA is the ability to create your own custom functions (also known as user-defined functions). This book covers how to create your own user-defined functions as well as how to save a function as an Excel add-in.