Runtime Error 425: “Invalid object use,” explained and fixed
Error 425, “Invalid object use”, fires when code treats an object as something it is not: using an object reference as a plain value, assigning an object without Set (or with Set where a value belongs), or handing an object to an operation that only accepts scalars or a specific object kind. VBA is strict about the line between objects and values, and error 425 is that strictness speaking. The object usually exists and is fine; the way it was used in the statement is not.
For people who just run the program
- This is a code-level error with no user-side cause. It appears in macros and compiled tools alike when a statement misuses an object; documents and data do not trigger it.
- Note the action and move on. There is nothing to retry differently; the same statement misuses the object the same way every run.
- Send the number to the maintainer. Error 425 narrows the fault to object-handling in one statement, which makes it one of the quicker diagnoses in this family.
- If it began after an update, say so. A variable whose type changed in a new version (from a value to an object, or back) flips previously fine statements into this error, and that timing helps locate the edit.
For people who write the code
- Check Set discipline at the failing statement. Object assignments need
Set; value assignments must not use it. The two classic shapes:
Set ws = wb.Worksheets(1) ' object: Set required
total = ws.Range("A1").Value ' value: no Set, and .Value is explicit
' ws = wb.Worksheets(1) ' error 425 territory
- Name the default member you mean. Writing an object where a value is expected makes VBA reach for the object's default property; where there is none, or the reach is ambiguous, error 425 results. Writing
.Value, .Text, or the intended property explicitly removes the ambiguity and states intent.
- Do not pass objects to scalar parameters. Functions declared to take numbers or strings will raise 425 when handed an object that has no usable default. Extract the scalar first, then pass it.
- Watch class instances in expressions. Your own classes have no default member unless you define one; using an instance in arithmetic or concatenation is invalid object use until you add a default property or call a member explicitly.
Error 425 often appears after a variable's type changes. Code written when a variable held a string starts failing when it is redeclared as an object (or the reverse), because every statement using it silently changes category. When 425 appears after a refactor, review the variable's declaration before its uses.
If it still happens
If Set usage is correct and the property is explicit, the object may be of an unexpected class whose same-named member behaves differently (a control versus a class with the same interface). TypeName the object at the failure and compare with the class the code was written against.
Common questions
What is the difference between error 425 and error 424? Error 424 (“Object required”) means a statement needed an object and got none, or referenced one that does not exist. Error 425 means an object was supplied but used in a way objects cannot be used, as a value, or with the wrong assignment form.
Why does VBA separate objects from values so strictly? Because an object is a reference to something with behavior, not a piece of data. Set marks reference assignment explicitly so the language never has to guess whether you meant the object or one of its values.
Related errors