Variable not yet created in this context

A variable has to be created before it can be displayed in the Watch window or the Immediate window, and before it can have values assigned to it in the Immediate window. This error has the following causes and solutions:

  • You tried to display the value of a local variable that you just entered in your code before executing at least a Single Step command in break mode.

    Step into the code to force compilation of the new statement.

  • You tried to display the value of a local variable that you just added in a procedure farther down the call chain by moving to the procedure using the Calls dialog box.

    You have to actually return to the procedure before you can display the variable in its context.

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

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.