Skip to content

Introduction

In this guide we introduce the reader to VBA, and how it can be used to build user defined functions (UDFs) to achieve low-level data and/or task automation.

Visual Basic for Applications, or VBA for short, is an implementation of Microsoft’s event-driven programming language Visual Basic 6. Ever since it was first introduced in 1993, it has been very popular for achieving automation in Excel, and business users have created millions of macros with it. This still holds true today.

The popularity of VBA, however, has been falling since its peak in 2004, as other, more modern alternatives have emerged that let business users create processes that are more secure and scalable.

For example:

  • Importing data using Power Query (Get & Transform) instead, where the code is more sustainable and does not rely as much on the original developer.
  • Automation in Excel Online with Office Scripts (TypeScript)
  • Gathering data with Power Apps
  • Automation of other Office 365 applications, such as Outlook, using Power Automate
  • The introduction of Excel’s new dynamic arrays, and of functions such as LET and LAMBDA

That said, VBA still has its place in the office. A major reason why VBA is used so frequently is that it does not require resources from an IT department. Providing training or low-code resources (such as Power Apps) can be time-consuming or costly, whereas business users can improve efficiency relatively easily with VBA.

Also, other technologies such as Office Scripts are still relatively nascent and do not record events, which means that Office Scripts cannot determine which cell is currently selected. In VBA, event-driven programming, where actions are triggered by the selection of a particular cell, is quite possible.

In the rest of this guide, we go through some practical examples of how VBA can be used to help with:

  • Improving data integration tasks between databases and local Excel tables, e.g. with user forms
  • Importing live or near real-time data from external online datasets
  • Automating workbook tasks and calculations
  • Creating advanced custom functions
  • Achieving better workbook navigation

Click ahead to find out more.