Microsoft KB Archive/818808

= You may receive a &quot;Run-time error 1004&quot; error message when you programmatically set a large array string to a range in Excel 2003 =

Article ID: 818808

Article Last Modified on 2/5/2007

-

APPLIES TO


 * Microsoft Office Excel 2003

-



SYMPTOMS
In Office Excel 2003, when you programmatically set a range value with an array containing a large string, you may receive an error message similar to the following:

Run-time error '1004'.

Application-defined or operation-defined error.



CAUSE
This issue may occur if one or more of the cells in an array (range of cells) contain a character string that is set to contain more than 911 characters.



WORKAROUND
To work around this issue, edit the script so that no cells in the array contain a character string that holds more than 911 characters.

For example, the following line of code from the example code block below defines a character string that contains 912 characters: Sub XLTest Dim aValues(4) aValues(0) = &quot;Test1&quot; aValues(1) = &quot;Test2&quot; aValues(2) = &quot;Test3&quot; MsgBox &quot;First the Good range set.&quot; aValues(3) = String(911, 65) Range(&quot;A1:D1&quot;).Value = aValues MsgBox &quot;Now the bad range set.&quot; aValues(3) = String(912, 66) Range(&quot;A2:D2&quot;).Value = aValues End Sub



MORE INFORMATION
A character string is a series of characters that are manipulated as a group. The length of a character string is typically the number of characters in it, or the length is pre-defined, as it is in this case.

Additional query words: XL11 XL2003

Keywords: kberrmsg kbbug KB818808

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.