VBA raises Runtime Error 438: Object doesn’t support this property or method when code calls a property or method that does not exist on the target object. This usually stems from typographical errors in method names, confusing one Excel object with another (such as calling a Worksheet property on a Range), or using late binding where the compiler cannot verify object syntax ahead of time.
Quick Answer
Resolve Error 438 by fixing typographical errors in the property or method name, confirming that the targeted object actually contains that member (such as using
.Valueon aRangeinstead of.Texton aWorksheet), and using early binding with explicit variable declarations (Dim ws As Worksheet) so the compiler catches invalid calls before runtime.
Anatomy of an Invalid Member Call
Unlike lower-level languages where calling a non-existent method generates an immediate compilation error, VBA allows late binding via the generic Object or Variant data types. If an object’s type is undefined at compile time, VBA delays member validation until the line executes:
Dim obj As Object
Set obj = Worksheets("Sheet1")
' Sheets do not have a .ClearContents method (Ranges do):
obj.ClearContents ' FAILS: Runtime Error 438
Because obj was declared generically as Object, the Visual Basic Editor allowed the code to compile. Only when execution reached the statement did Excel discover that Worksheet has no ClearContents method.
Common Triggers and Corrective Actions
1. Confusing Ranges, Worksheets, and Workbooks
Developers frequently mix up the scope and capabilities of different objects in the Excel object model:
| Attempted Call | Why It Triggers Error 438 | Correct Call |
|---|---|---|
Worksheets("Data").ClearContents | ClearContents belongs to Range, not Worksheet. | Worksheets("Data").Cells.ClearContents |
Range("A1").Sheet | Range has no .Sheet property. | Range("A1").Worksheet |
Workbook.Range("A1") | Range belongs to Worksheet, not Workbook. | Workbook.Worksheets(1).Range("A1") |
ActiveCell.Text = "Done" | .Text on a cell is read-only. | ActiveCell.Value = "Done" |
2. Typos in Properties and Methods
VBA properties and methods are not case-sensitive, but every character must match. Common typos include:
- Calling
.Valuinstead of.Value - Calling
.FormulaArray = ...on a whole table object instead of a range - Calling
.Count()as a method when it is a property.Count
The Fix: Use Early Binding and Explicit Types
Declaring variables with explicit object types prevents Error 438 entirely during compilation. When you press Debug > Compile VBAProject, the editor immediately highlights any non-existent properties:
' Risky (Late Binding):
Dim target As Object
Set target = ActiveSheet.Range("A1")
target.Valu = 10 ' Compiles silently, crashes at runtime with Error 438
' Safe (Early Binding):
Dim target As Range
Set target = ActiveSheet.Range("A1")
target.Valu = 10 ' Flagged immediately at compile time: "Method or data member not found"
To enforce clean syntax across every module in your workbook, review the guidelines in “Variable not defined”: Why you must use Option Explicit..