For Each can only iterate over a collection object or an array

This page is specific to the Visual Basic for Applications (VBA) Language Reference for Office 2010.

The For Each construct can only be used with collections and arrays. This error has the following cause and solution:

  • You specified an object that isn't a collection or array as the group part of the For Each syntax. Check the spelling of the item over which you want to iterate to make sure it corresponds to a collection or array in scope in this part of your code.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).