Can't Set Value Property in For Each with Variant Type (107903)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q107903 SUMMARY
The default value property of an object or an element in an array cannot be
set with a For Each loop if the loop control variable is a Variant data
type.
WORKAROUND
If you are working with a collection of objects, use an explicit value
property (cellItem.value=cellItem & "A") or use the Dim statement to
declare the control variable as an Object rather than a Variant data type.
If you are working with an array, there is no workaround: when you use a
For Each loop with an array, you have read-only access. Although you do not
receive an error message if you attempt to write to an array, the array
element will not be written to.
REFERENCES
For additional information about getting help with Visual Basic for
Applications, please see the following article in the Microsoft Knowledge
Base:
163435 VBA: Programming Resources for Visual Basic for Applications
Modification Type: | Minor | Last Reviewed: | 10/10/2006 |
---|
Keywords: | kbdtacode kbprb kbProgramming KB107903 |
---|
|