Excel VBA Object Required Error: Causes and Fixes

VBA & macros · Updated November 20, 2026

In Excel VBA, “Object required” is run-time error 424: VBA reached a statement that needs an object, such as a worksheet or range, but the value or reference supplied is not a usable object. Check the highlighted line, confirm the variable is declared and assigned as an object, and use Set when assigning an object reference; also distinguish error 424 from error 91, which usually means an object variable is Nothing.

What error 424 means

VBA objects represent things with properties and methods: a Workbook has Worksheets, a Worksheet has a Range, and a Range has properties such as Value. Error 424 means VBA cannot use the expression in a place where one of these objects is required. The failure is usually about the type or state of a reference, not about the contents of a cell.

For example, a string containing a worksheet name is not itself a Worksheet object. You must use that name to retrieve a worksheet from a workbook’s Worksheets collection before calling worksheet members. Similarly, a cell’s displayed text is a value; it is not interchangeable with the Range object that contains it.

Error 424 is a run-time error, so VBA can often compile the procedure and only stop when it reaches the problematic statement. The highlighted line is the immediate point of failure, though the cause may be earlier: a variable may never have been assigned, or an earlier branch may have left it holding the wrong kind of value.

Object references and the Set keyword

VBA distinguishes an object reference from a value. Assigning a number, string, or Boolean uses ordinary assignment. Assigning a reference to a Workbook, Worksheet, Range, or other object uses Set. Omitting Set when assigning an object is a frequent source of errors or confusing behavior, because VBA may try to evaluate a default property rather than store the object reference.

In this example, each variable is declared with the object type it is meant to hold. The assignments use Set, while the final line assigns a string to a cell’s Value property:

Sub WriteCell()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim target As Range

    ' Store object references, not cell values.
    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Data")
    Set target = ws.Range("A1")

    ' Value is a property, so this assignment does not use Set.
    target.Value = "Ready"
End Sub

This procedure assumes that the workbook containing the macro has a sheet named Data. If that sheet does not exist, the lookup normally raises a different error, such as “Subscript out of range” (error 9), rather than error 424. That distinction is useful: the error message narrows the diagnosis, but you still need to check the exact expression and the actual line VBA highlights.

Common causes in Excel macros

Several different mistakes can leave VBA with something other than the object a statement expects. Look for these patterns when investigating error 424:

  • A variable has the wrong type. A variable declared as String or Variant may contain a sheet name or cell value, then later be used as though it were a Worksheet or Range.
  • An object variable was not assigned. A conditional branch may skip the Set statement, or code may attempt to use a reference before initializing it. Dereferencing a variable that is Nothing more commonly produces error 91, but checking assignment is still essential.
  • An object assignment is missing Set. Use Set ws = ... to store a Worksheet reference. Do not confuse that with setting a cell’s value, which is an ordinary property assignment.
  • A member is being called on the wrong thing. A variable holding a number or text cannot provide worksheet properties such as Cells or Range. Check the declaration and what was most recently assigned to it.
  • A reference is incomplete or ambiguous. Unqualified references such as Range("A1") depend on the active sheet. They are not inherently invalid, but a different active sheet can make a macro operate on the wrong object or expose a related failure.
  • A procedure expects an object argument. If a procedure takes a Worksheet or Range parameter, passing text or a value instead of the actual object can cause a problem at the call or when the argument is used.

A useful distinction: Set is for the reference itself, not every statement that mentions an object. For example, target.Value = "Ready" changes a property on a Range object; adding Set there would be inappropriate because Value is a value, not an object reference.

How to find the failing reference

When the error dialog appears, choose Debug rather than immediately dismissing it. The Visual Basic Editor highlights the statement that failed. Read the whole statement from left to right: the failure may be in a worksheet lookup, a chained member such as ws.Range, or an argument passed to a procedure.

  1. Note the highlighted statement and identify each variable or function result in it.
  2. Check each variable’s declaration. Is it meant to be a Workbook, Worksheet, Range, or a value such as String?
  3. Step through the procedure one line at a time with the editor’s debugging controls. Watch for branches that skip assignment or overwrite the variable.
  4. Inspect relevant variables in the Locals window or add temporary Debug.Print statements for values and types.
  5. Confirm that the object belongs to the intended workbook and worksheet, rather than relying on whichever workbook or sheet is active.

Do not assume that the line containing a cell address is always at fault. A variable may be set incorrectly several lines earlier, or a helper function may return a value when the caller expects an object. If the editor highlights a procedure call, inspect both the arguments and the procedure’s parameter declarations.

For object variables, check whether they are Nothing before using them. An object-typed variable can be tested with If ws Is Nothing Then. That test is not appropriate for ordinary strings or numbers. Conversely, IsEmpty checks a Variant’s empty value; it is not a substitute for checking whether an object reference is Nothing.

Use explicit workbook, worksheet, and range references

Excel offers convenient shorthand, but unqualified references depend on context. Range("A1") and Cells(1, 1) generally refer to the active sheet when used without a worksheet qualifier. If a user activates another sheet while a macro runs, the code may read or change a different location than intended. Qualifying the reference makes its owner clear and helps prevent a separate class of workbook bugs.

ThisWorkbook means the workbook containing the VBA code. ActiveWorkbook means the workbook currently active in Excel; these may differ, for example when a macro in an add-in acts on a user’s open file. Choose deliberately. The following example checks whether a named sheet exists before using it:

Save a copy of the workbook before running or adapting a macro. VBA changes cannot be undone with Ctrl+Z, so a copy provides a practical recovery point.

Sub CheckDataSheet()
    Dim ws As Worksheet

    ' Limit error suppression to the worksheet lookup.
    On Error Resume Next
    Set ws = ThisWorkbook.Worksheets("Data")
    On Error GoTo 0

    If ws Is Nothing Then
        MsgBox "The Data worksheet was not found."
        Exit Sub
    End If

    ' Use the verified worksheet explicitly.
    ws.Range("A1").Value = "Ready"
End Sub

The short use of On Error Resume Next lets the lookup fail without stopping the procedure; On Error GoTo 0 immediately restores normal error handling. Do not leave error suppression active across unrelated code, because it can hide the real problem and allow later statements to run with missing references.

Why error 91 is different

Error 91, “Object variable or With block variable not set,” is closely related but not identical. It commonly occurs when a variable is a valid object variable whose value is Nothing, and code tries to use one of its properties or methods. Error 424 instead says that the expression at the point of use is not an object of the kind required. In practice, the messages can appear in similar debugging situations, so inspect both the variable’s declared type and whether it has actually been assigned.

For example, a failed lookup handled with On Error Resume Next may leave a Worksheet variable as Nothing. Testing it before using ws.Range prevents the later dereference. But if the variable was declared as a String containing “Data,” checking whether it is Nothing does not make it a worksheet; retrieve the Worksheet object from the Worksheets collection first.

Prevent the error with clearer VBA

Good habits make object errors easier to prevent and diagnose. Declare variables with specific types instead of using Variant by default, give them names that reveal their role, and assign references close to where they are used. Keep object lookup, validation, and work with the object as separate steps.

  • Use Option Explicit at the top of a module so misspelled variable names are caught during compilation.
  • Qualify ranges with a worksheet, and worksheets with a workbook, when the intended owner matters.
  • Check whether a lookup succeeded before calling methods or properties on its result.
  • Use Set for object references and ordinary assignment for properties such as Value.
  • Keep error handling narrow. Handle an expected missing sheet explicitly rather than suppressing every error in a long procedure.
  • Compile the VBA project from the Visual Basic Editor after changes. Compilation catches many syntax and declaration problems, although it cannot guarantee that every reference will be valid at run time.

Excel for Microsoft 365 on Windows runs VBA in the desktop application. Excel for the web cannot create, run, or edit VBA macros; open the workbook in desktop Excel to work with its VBA project. Excel for Mac also supports VBA, but Windows-specific components such as some ActiveX controls and Windows API calls may not work there. The object-reference principles described here are general VBA concepts, though platform-specific code may need separate adjustments.

Frequently Asked Questions

What does Object required mean in Excel VBA?
It is run-time error 424. VBA expected an object, such as a Worksheet or Range, but the expression supplied was not a usable object reference. Inspect the highlighted line and check the variable’s type and assignment.

Does Object required mean I forgot Set?
Missing Set is a common cause when assigning an object reference, but it is not the only one. A wrong variable type, an incorrect expression, or a value used where an object is expected can also be responsible. The exact line and declaration determine the fix.

What is the difference between error 424 and error 91?
Error 424 says an object is required at the failing expression. Error 91 usually indicates that an object variable or With block variable has not been set and is Nothing when used. Both call for checking how the reference was obtained and whether it is valid before use.

Why does my VBA code work on one sheet but fail on another?
Unqualified references such as Range("A1") can act on the active sheet. If the active sheet changes, the macro’s target changes too. Qualify the range with the intended Worksheet, and qualify that worksheet with the intended Workbook.

Can I run a VBA macro in Excel for the web?
No. Excel for the web can preserve a workbook containing macros, but it cannot run or edit VBA code. Use desktop Excel for Windows or Mac to work with VBA, noting that some Windows-specific features are not portable to Mac.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.