Locked lesson.
About this lesson
Using a For Each loop to cycle through each object in a collection such as each worksheet in a workbook's worksheets.
Exercise files
Download this lesson’s exercise file.
Loops: Looping through collections with For Each x in y loops.xlsm23.2 KB
Quick reference
Loops: Looping through collections with For Each x in y loops
Looping through each item in a collection
When to use
When you wish to loop through each item within a collection of items (e.g. each worksheet within a workbook).
Instructions
For Each loop syntax
For Each <object> In <collection>
‘Do Something
Next <object>
Hints & tips
- Including the <object> in the Next line is optional, but recommended to make your code easier to read
Lesson notes are only available for subscribers.