Runtime Error 449: “Argument not optional,” explained and fixed

Error 449, “Argument not optional”, fires when a procedure or method is called without an argument it requires. VBA marks parameters optional only when declared Optional; everything else must be supplied on every call. The error usually means a call site written against a version where the parameter was optional (or absent), or a programmer who assumed a trailing parameter could be skipped like in some other languages. The fix is to supply the argument, with a sensible value, at that call.

For people who just run the program

  1. This is a code defect, surfaced where macros call shared routines or library methods. No document or data state changes it.
  2. Note the feature and any recent updates. A call that omits an argument fails only when the callee changes to require it, so “started after the library updated” is meaningful evidence.
  3. Nothing to adjust on your side. Settings and files cannot supply a missing argument; only the code can.
  4. Report the number and the feature. The maintainer's fix is localized to one call site.

For people who write the code

  1. Find the call and the signature. Compare the arguments supplied against the declaration of the procedure actually being called (the referenced version, not the intended one). The missing required parameter is the gap.
  2. Function TotalPrice(qty As Long, unit As Currency, _
                        Optional taxRate As Double = 0) As Currency
    ' TotalPrice(3)            ' error 449: unit is not optional
    ' TotalPrice(3, 9.99)      ' fine: only taxRate may be omitted
  3. Respect the all-or-nothing rule for named skipping. Omitting a middle argument positionally needs a placeholder comma; omitting by simply not mentioning a required named argument is error 449, not a default.
  4. When evolving shared procedures, add new parameters as Optional with defaults. Making a new parameter required breaks every existing caller with 449. Optional-with-default keeps old calls valid and lets new calls opt in.
Error 449 in Automation can mean the argument is required by the object, not by your declaration. External libraries enforce their own signatures; a parameter their documentation calls optional in one version may be required in the installed one. The installed library's Object Browser entry is authoritative.

If it still happens

If every argument is visibly supplied, the call may be binding to a different procedure than intended: an overloaded-looking name in another module or library with a longer signature. Qualify the call with its module or class and recompile; resolution surprises of this kind are common in projects with many same-named helpers.

Common questions

What makes an argument optional in VBA? Only the Optional keyword in the declaration, optionally with a default value. Any parameter without it must be supplied on every call; there is no other way for a caller to skip it.

Can error 449 be caught at compile time? Yes for early-bound calls: the compiler flags a missing required argument before the code runs. It reaches run time mainly through late-bound Automation calls and dynamic invocation.

Related errors

Runtime Error 448 · Runtime Error 450 · Runtime Error 35