Excel 2010 Chart SetSourceData 1004 error

pocerus

New Member
Joined
Oct 22, 2014
Messages
1
Hello,

I have a problem with an Excel application that was written in my company using Office 2003. It has always worked properly in Office 2003 but when I run it in Office 2010 I get an error message after executing the SetSourceData to apply a Range taken from a group of cells in the WorkSheet.

The error message is the following: Run-time error '1004':

Method 'SetSourceData' of object'_Chart' failed.

I have tested the following code in an Excel file in Office 2010 and 2003 and the error only comes up in Office 2010.
Code:
Sub callSetSourceData()
Dim range As Range
Dim chartt As ChartObject
Set chartt = ActiveSheet.ChartObjects("Chart 1")

On Error GoTo DelSeries:
For i = 0 To 10000
    chart.Chart.SetSourceData Source:=ActiveSheet.Range("A1:FA6")
Next i
Exit Sub

DelSeries:
    For Each series In chart.Chart.SeriesCollection
        series.Delete
    Next series
    Resume Next
End Sub
Any ideas on how to solve this problem or why the behaviour of VBA/Chart has changed from one Office version to another?

Many thanks for your help
 
Last edited by a moderator:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
As I mentioned here (and please read the rules about cross-posting), that can't be the actual code. Please post the real code verbatim.
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top