VBA throws Runtime Error 1004: Method ‘Range’ of object ‘_Worksheet’ failed when your macro attempts to reference an invalid cell address, qualifies the boundary cells of a range with a different worksheet than the parent range, or evaluates an unassigned variable inside the Range() property.
What Causes Runtime Error 1004: Method ‘Range’ of object ‘_Worksheet’ Failed?
Runtime Error 1004: Method ‘Range’ of object ‘_Worksheet’ failed occurs when VBA cannot evaluate a
Range()call. The primary causes are unqualifying inner cells in a two-cellRange(Cell1, Cell2)call across worksheets, invalid cell coordinates (such as dynamic row variables returning 0 or text), or referencing non-existent named ranges.
Quick Fix for the Most Common Trigger
The most frequent trigger is nesting cells from one sheet inside a range reference qualified to a different sheet:
' BROKEN: The inner Cells inherit the ActiveSheet, conflicting with wsTarget
wsTarget.Range(Cells(1, 1), Cells(10, 5)).Value = 100
' FIXED: Fully qualify both the parent Range and the boundary Cells
With wsTarget
.Range(.Cells(1, 1), .Cells(10, 5)).Value = 100
End With
If your code already qualifies both cells, the issue lies in your address string or variable values.
Root Causes and Diagnostic Steps
When troubleshooting this error, examine the line highlighted in yellow by the VBA debugger. The failure points fall into four distinct categories.
1. Unqualified Inner Cells in Multi-Cell Range Calls
When using the two-argument syntax Worksheets("Sheet1").Range(arg1, arg2), Excel requires both inner arguments to point to the exact same worksheet instance as the outer Range.
If Sheet2 is active while your code runs:
Dim ws As Worksheet
Set ws = Worksheets("Data")
' This crashes because Cells(1, 1) defaults to ActiveSheet (Sheet2), not "Data"
ws.Range(Cells(1, 1), Cells(5, 5)).ClearContents
To resolve this, qualify each inner reference using a With block:
Dim ws As Worksheet
Set ws = Worksheets("Data")
With ws
.Range(.Cells(1, 1), .Cells(5, 5)).ClearContents
End With
2. Invalid or Zero-Index Row/Column Variables
VBA coordinates in Cells(row, col) are 1-based. If a variable calculating the last row or column returns 0 or a negative number, the Range method immediately fails:
Dim lastRow As Long
lastRow = Cells(Rows.Count, "A").End(xlUp).Row ' If column A is blank, lastRow = 1
' If an offset or calculation reduces this to 0:
lastRow = lastRow - 1 ' Evaluates to 0
Range("A" & lastRow).Value = "Test" ' Runtime Error 1004
Verify your row and column variables before passing them into Range(). You can inspect variable values at break mode by opening the Immediate Window (press Ctrl + G) and checking values with ?lastRow. For step-by-step guidance, see How to use the Immediate Window to debug variable values in real-time.
3. Syntax Errors in String-Based Addresses
Constructing range strings with dynamic string concatenation frequently causes syntax errors when commas, colons, or quotation marks are misplaced:
' INCORRECT: Missing colon separator creates "A1B10"
Range("A1" & "B10").Select
' INCORRECT: Produces "A:0" when variable evaluates to 0
Range("A1:A" & iRow).Copy
' CORRECT:
Range("A1:B10").Copy
Range("A1:A" & iRow).Copy ' Ensure iRow >= 1
4. Broken or Missing Named Ranges
Referencing a Named Range via Range("MyNamedRange") will trigger this error if the name has been deleted, spelled incorrectly, or scoped strictly to a specific worksheet rather than the workbook level:
' Fails if "DepartmentList" is scoped only to Sheet2 while code runs against Sheet1
Sheets("Sheet1").Range("DepartmentList").Font.Bold = True
' Fix: Reference the sheet where the local scoped name lives
Sheets("Sheet2").Range("DepartmentList").Font.Bold = True
Systematic Diagnostic Flowchart
If the error persists after checking basic range syntax, step through this diagnostic sequence:
- Check Sheet Activation: Does the code run on a background sheet? Calling
.Selector.Activateon a range belonging to an inactive sheet triggers a 1004 break. For deeper context, review Runtime Error 1004: Why ActiveSheet references cause failures in background macros.. - Inspect Sheet Existence: Ensure the worksheet object variable is successfully pointing to an open tab. If the sheet name was changed, your code may instead generate Runtime Error 9: Subscript out of range (Calling a Worksheet that doesn’t exist)..
- Verify Protection Status: If the sheet or cells are locked, certain operations on
Rangefail silently or throw error 1004. - General 1004 Categorization: If your range call is syntactically sound and not referencing a worksheet mismatch, review the master index at Troubleshooting VBA Runtime Error 1004: The Definitive Fix Guide or the broad application error breakdown in Runtime Error 1004: Application-defined or Object-defined error (The Catch-all)..