How to Fix Excel VBA Error 1004 Cannot Use That Command on Overlapping Selections

Automating data extraction, worksheet merging, and tabular restructuring in Microsoft Excel using Visual Basic for Applications (VBA) often involves copying ranges using Range.Copy or manipulating multi-area selections via Union. When running a macro, Excel frequently halts execution with: Run-time error ‘1004’: That command cannot be used on overlapping selections. This runtime exception occurs when code attempts to execute copy, cut, or formatting operations across multiple non-contiguous ranges that intersect each other, or when whole-column selections overlap filtered tables.

Eliminate Intersecting Ranges in Union Statements

The standard architectural cause of this error is inadvertently combining ranges that share overlapping cells before executing a copy command:

Sub SafeMultiAreaCopy()
    Dim ws As Worksheet
    Dim rng1 As Range, rng2 As Range, combinedRng As Range
    
    Set ws = Worksheets("Data")
    Set rng1 = ws.Range("A1:C10")
    Set rng2 = ws.Range("B5:D15") ' Overlaps with rng1!
    
    ' Copy ranges individually to prevent overlapping selection exceptions
    rng1.Copy Destination:=Worksheets("Report").Range("A1")
    rng2.Copy Destination:=Worksheets("Report").Range("E1")
End Sub

Copy Visible Cells After Filtering Without Range Overlap

When applying filters and selecting visible cells with SpecialCells(xlCellTypeVisible), including the entire column range (e.g. Columns("A:D")) alongside header ranges causes overlap exceptions:

  1. Explicitly restrict the copy target to the exact populated table body:
    Dim lastRow As Long
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    
    ' Target only active data rows to prevent whole-sheet buffer collisions
    ws.Range("A2:D" & lastRow).SpecialCells(xlCellTypeVisible).Copy _
        Destination:=Worksheets("Summary").Range("A2")
  2. Restricting operations to bound cell coordinates guarantees Excel processes non-overlapping rectangular blocks.

Avoid Selecting Ranges Prior to Copying

Refrain from invoking .Select or Selection.Copy in automated macros. Direct referencing (SourceRange.Copy Destination:=TargetRange) bypasses the Windows clipboard pipeline, eliminating selection geometry clashes entirely.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.