For Each may not be used on array of user-defined type or fixed-length strings

For Each constructs are only valid forcollections andarrays of intrinsic types, including arrays of objects. Also, arrays of fixed-length strings can't be iterated using For Each. This error has the following causes and solutions:

  • The elements of the array in your For Each construct have auser-defined type.

    Use an ordinary For...Next loop to iterate the elements of the array.

  • The elements of the array in your For Each construct have a fixed-length string type. Use an ordinary For...Next loop to iterate the elements of the array.

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