Runtime Error 1004: Fixing errors when using Name := in charts.

VBA throws Runtime Error 1004 when assigning the Name property or using the parameter Name := on a chart object, chart series (SeriesCollection), or ChartTitle if the string syntax violates Excel’s naming rules, attempts to rename a series using invalid range syntax, or conflicts with the chart type’s structural layout.

Quick Answer

When naming a chart series using a cell reference, pass the reference as a string containing an exact external formula (e.g., ="=Sheet1!$B$1"), not a plain cell address or unqualified range. When setting the series name to plain text, assign a literal string without an equal sign, or use .Name = "Direct Text".


The Two Ways to Name a Chart Series

In Excel VBA, a chart series (Series object) can derive its name in two ways:

  1. As Static Text: The series name is a fixed string (e.g., "2026 Revenue").
  2. As a Dynamic Cell Reference: The series name links to a cell on a worksheet (e.g., cell B1).

Confusion between these two methods is the primary trigger of Runtime Error 1004.

' FAILS with Error 1004:
cht.SeriesCollection(1).Name = Sheet1.Range("B1") ' Implicit value assignment breaks
cht.SeriesCollection(1).Name = "Sheet1!B1"        ' Missing the required equal sign

How to Fix Series Naming Errors

1. Linking a Series Name to a Cell (Dynamic Reference)

When linking a chart series name to a worksheet cell, Excel requires the string to be formatted exactly like a worksheet formula, including an equal sign, worksheet name, and absolute coordinates ($).

Sub SetDynamicSeriesName()
    Dim cht As Chart
    Set cht = ThisWorkbook.Worksheets("Dashboard").ChartObjects("SalesChart").Chart

    ' CORRECT: Full formula syntax with leading equal sign and absolute coordinates
    cht.SeriesCollection(1).Name = "='Dashboard'!$B$1"
End Sub

Alternatively, you can read the cell’s address programmatically:

Dim targetCell As Range
Set targetCell = ThisWorkbook.Worksheets("Dashboard").Range("B1")

' Programmatic formula assignment
cht.SeriesCollection(1).Name = "='" & targetCell.Worksheet.Name & "'!" & targetCell.Address(External:=False)

2. Setting a Static Text Label

If you want the series to have a static name rather than a linked formula, assign the string directly without an equal sign:

Sub SetStaticSeriesName()
    Dim cht As Chart
    Set cht = ThisWorkbook.Worksheets("Dashboard").ChartObjects("SalesChart").Chart

    ' Static text: No equal sign, literal string only
    cht.SeriesCollection(1).Name = "Forecast Data"
End Sub

3. Renaming the Chart Object vs. the Chart Title

A common source of confusion is assigning names to the wrong level of the chart hierarchy:

  • ChartObject (The Container): The shape on the sheet. Renaming this alters how you reference the shape in code: ws.ChartObjects(1).Name = "RevenueChart"
  • ChartTitle (The Display Heading): The visual banner at the top of the chart: ' If HasTitle is False, assigning Text causes Error 1004 With cht .HasTitle = True .ChartTitle.Text = "FY26 Operational Metrics" End With

If your macro encounters missing references or fails while configuring data points, see #REF! in Graph/Chart Data Series and Handling Errors in Chart Labels (Avoiding #N/A in Data Callouts).


Diagnostic Summary Table

Error ScenarioPrimary CauseFirst-Line Fix
PivotTable wizard method failedBlank source headers, overlapping target, or protected sheet.Modernize with PivotCaches.Create; verify all source columns have text headers.
Method ‘Open’ of object ‘Workbooks’ failedFile is corrupt, requires a password, or is blocked by Protected View.Pass Password:="..." or CorruptLoad:=xlRepairFile; unblock file properties in Windows.
Errors when using Name := in chartsMalformed cell reference string or setting chart titles when .HasTitle = False.Use formula format ="='Sheet'!$A$1" for linked cell names; ensure .HasTitle = True.

Next Diagnostic Steps

If your chart, PivotTable, or file-opening scripts run inside loops across large collections, ensure you are cleaning up memory and handling application states properly by reviewing Excel Crashing on Close: How to properly clear Object variables from memory.. If you need to isolate which line of a complex macro is triggering a failure, refer to How to find the exact line causing a crash using Erl..