For Each Statement

Syntax

For Each var In items
    statements
Next [var]

Group

Flow Control

Description

Executes statements for each item in items.

Parameters

Parameters Description
var The iteration variable.
items The collection of items to perform.

Example


Sub Main
    Dim Document As Object
    For Each Document In App.Documents
        Debug.Print Document.Title
    Next Document
End Sub

See also

Do, For, Exit For, While