Table of contents
TOC
Collapse the table of content
Expand the table of content

Variable required. Can't assign to this expression

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

This error typically occurs when you attempt to assign a value to something that can't accept the assignment. This error has the following causes and solutions:

  • You attempted to use a numeric expression as anargument to the Len function.

    The Len function doesn't accept a numeric expression, a numeric literal, or a binary numeric expression, but it does accept either a string or numeric variable, astring expression, or a variable ofuser-defined type.

  • You used a function call or an expression as an argument to Input #, Let, Get, or Put. For example, you may have used an argument that appears to be a valid reference to anarray variable, but instead is a call to a function of the same name.

    Input #, Let, Get, and Put don't accept function calls as arguments.

  • You attempted to assign a value to an identifier previously declared as aconstant.

    Choose another name for the identifier.

  • You tried to use a nonvariable as a loop counter in a For...Next construction. Use a variable as the counter.

  • You tried to assign a value to a read-only property or to an expression that consists of more than one variable (such as X + Y). An assignment places a value at a memory location. The specified expression must represent a single, writable location.

    Rewrite the assignment to a single variable name that can accept the data.

  • You tried to use an undeclared variable that is defined as a constant in a type library.

    Either use a different name for the variable, or declare it explicitly.

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

© 2018 Microsoft