Runtime Error 35: “Sub, function, or property not defined,” explained and fixed

Error 35, “Sub, function, or property not defined”, means a call was made to a procedure that VBA cannot find when the code runs. The name may be misspelled, the procedure may have been deleted or made Private in another module, or the library that provides it is not referenced. In Office documents it also appears when a macro calls into an add-in that is not loaded. It is a code and references problem, never a data problem.

For people who just run the program

  1. Note whether it started after an update. Error 35 commonly appears the first time an updated workbook meets an older add-in, or the reverse: one half of a pair changed and the other did not.
  2. Check that the companion add-in or template is loaded. If the tool ships as two files, both must be present and enabled; macros that call into a missing partner fail with this error.
  3. Do not enable macros from a different source to “complete” the set. The missing procedure belongs to a specific file; random downloads will not match it and are a security risk.
  4. Send the maintainer the error and your Office version. Whether the call fails everywhere or only on some machines separates a code typo from a missing reference.

For people who write the code

  1. Compile the project first. Debug, Compile catches most undefined calls before run time. If it compiles clean and still fails at run time, the call is being made dynamically, through Application.Run, CallByName, or an event name stored as text.
  2. Application.Run "BuildReport"   ' fails with 35 if the name is wrong
                                     ' or the workbook holding it is closed
  3. Search the whole project for the name. Renames that miss one call site are the top cause. Search current project, not current module, and include the called name's old spelling if it was ever renamed.
  4. Check references for MISSING entries. Tools, References: a library marked MISSING makes its procedures undefined and can also break unrelated built-in functions. Uncheck or re-point the missing reference.
  5. Mind scope. A Private procedure in another module, or a procedure in a form module called without qualifying the form, is “not defined” from the caller's point of view.
Error 35 at application start-up often means a start-up macro calls into something not yet loaded. Order matters: code in Auto_Open or Workbook_Open that calls an add-in procedure can fail simply because the add-in loads after the workbook.

If it still happens

If the name exists, is public, and compiles, suspect two procedures with the same name in different places and the wrong one winning, or a worksheet event name that no longer matches the control it belongs to (a renamed button keeps its old macro assignment). The call stack and the Object Browser together show which definition VBA resolved.

Common questions

Why does error 35 say “not defined” when the procedure exists? Because from the call site it is not reachable: it may be Private in another module, inside a form or class that needs qualifying, or in a workbook or add-in that is not open. Existence and reachability are different things in VBA.

Can a missing reference cause error 35? Yes. Procedures supplied by a referenced library become undefined when the reference breaks, and VBA reports the call as error 35 at run time.

Related errors

Runtime Error 429 · Runtime Error 449 · Runtime Error 453