0

I'm trying to store chart titles in a sheet into an array. I have the following code but it does not seem to work:

ReDim currentArray(1 To .ChartObjects.Count / 3) 
For i = 1 To .ChartObjects.Count Step 3
    .ChartObjects(i).chart.HasTitle = True
    title_name = .ChartObjects(i).chart.ChartTitle.Text
    If i = 1 Then
        Set currentArray(i) = title_name
    Else
        Set currentArray((i + 2) / 3) = title_name
    End If
Next

It gives me run-time error '424' message saying that object is required on line 6 where I try to store the title_name of the chart into currentArray. What other way is there to store just the chart names and not the charts themselves?

Community
  • 1
  • 1
user112947
  • 463
  • 4
  • 10
  • 17

1 Answers1

2

See eg What does the keyword Set actually do in VBA?

The Object Required (424) error means that the right-side of the assignment statement does not return an object, when an object is expected/required by the left side of the assignment statement.

Basically you only use the Set keyword when working with Objects. Remove Set each time and it should work fine.

Community
  • 1
  • 1
bobajob
  • 1,192
  • 6
  • 12