Skip to Main Content
Mastering VBA for Microsoft Office 365, 2019th Edition
book

Mastering VBA for Microsoft Office 365, 2019th Edition

by Richard Mansfield
July 2019
Beginner to intermediate content levelBeginner to intermediate
944 pages
27h 45m
English
Sybex
Content preview from Mastering VBA for Microsoft Office 365, 2019th Edition

Chapter 12Using Loops to Repeat Actions

As in life, so in macros. Sometimes, you'll want to repeat an action a predetermined number of times: break six eggs to make an omelet, write two letters, nap for 20 minutes.

Sometimes you know exactly how many times to repeat something. More often, though, you'll just repeat an action until a certain condition is met: break eggs until the pan is full, or nap until you wake up. In these situations, you don't know in advance when you'll fill the frypan or wake up. Your code must simply carry on until the condition is met. These, then, are the two types of loops: keep doing something until 1) you've done it a particular number of times or 2) you've finished the job.

In VBA, you use loops to repeat actions. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Excel 2016 VBA and Macros

Excel 2016 VBA and Macros

Bill Jelen, Tracy Syrstad
Excel 2016 Power Programming with VBA

Excel 2016 Power Programming with VBA

Michael Alexander, Richard Kusleika
Programming Excel with VBA and .NET

Programming Excel with VBA and .NET

Jeff Webb, Steve Saunders

Publisher Resources

ISBN: 9781119579335Purchase book