Excel Snippets

EXCEL VISUAL BASIC for APPLICATIONS (VBA)

Visual Basic for Applications (VBA) is a powerful, yet easy to learn programming language.

With it, repetitive tasks can be automated in Microsoft Office products such as Excel, Word, or PowerPoint.

Excelsnippets.com provides a free tutorial for using VBA in Excel, where it can augment and complement native Excel functions. Syntax here differs from VBA for Word or PowerPoint, so take care when surfing for tips on use.

VBA is a "behind the scenes" programming tool that comes with Microsoft Excel. It is an interpretative language, which means it does not run as a stand-alone package. You must have Excel open to run VBA programs.

Microsoft offers another package called Visual Basic (VB), which provides a means of creating stand-alone applications.

Although similar in some respects, VB and VBA programming languages are not the same. Excel VBA interacts with Excel workbooks and spreadsheets, whereas VB is a language to develop programs that can run independent of Excel.

A powerful aspect of Excel is the ability to enter formulas into spreadsheet cells. These perform calculations on data stored in other cells. This code remains "active" as long as the workbook is open.

If too many Excel formulas are stored in a workbook, processing speed slows. VBA can mitigate this problem. Its code is only active when the user runs it.

VBA macro code is stored in a VBA module that is invisible in a spreadsheet. You must invoke the VBA environment to see them. These macros can also operate on data stored in spreadsheet cells, but the syntax of Excel macros and VBA code differ from one another.

VBA code is more efficient than spreadsheet macros for performing calculations on large amounts of data, and VBA has greater functionality than spreadsheet formulas.

You do not need experience with Excel formulas to take advantage of the VBA coding tutorials. All you need is a basic understanding of spreadsheets. See Excel Basics.

Excelsnippets.com developed and tested all code snippets and examples using Excel 365.

Before embarking on the VBA tutorial, you must have Developer added to your Excel Ribbon, as outlined below. If you don't see it in your ribbon, add it now.

Customize the Excel Ribbon: Add Developer to the Ribbon

Adding Developer to the Excel Ribbon is fairly straightforward. From the File drop-down menu, select Options. If you don't see it, expand the menu by clicking on More at the bottom.

Access the File pull-down menu.

When you click on Options, the Excel Options dialog box appears. On the left-hand side of the selection panel is an option for Customize the Ribbon.

Select Customize Ribbon and then click the OK button in the lower right-hand side of the Excel Options dialog box. This will bring up the Customize the Ribbon dialog box with all available add-ins to the Excel Ribbon.

Check the box next to Developer on the right-hand side.

When the Customize the Ribbon dialog box appears, check the box next to Developer in the Main Tabs panel and click the OK button. Developer will now appear in the Excel Ribbon not only within this particular Excel workbook, but for all Excel workbooks that you open on your computer.

Now that you have Developer added to your ribbon, you are ready to begin the VBA tutorial for beginners. The modules for this tutorial on listed in the sidebar to the right, in the approximate suggested order.