Using Loops

It often happens in VBA code—particularly code that is intended to add, edit, copy, move, or delete data values—that you want to make reference to many values or cells or rows, one at a time. You might want to add recently obtained records to a set that already exists, or to edit many values by concatenating onto each a string such as @mydomain.com, or to add new records to a database table and assign them values from your worksheet.

By designing loops correctly, you can carry out actions a huge number of times and get your results with great speed and accuracy.

Using For-Next Loops

A For-Next loop is a fundamental structure in VBA code. It's a basic way of taking an action or set of actions a specified number of times. Here's a straightforward ...

Get Managing Data with Microsoft® Excel now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.