ActiveChart.SetSourceData is not working correctly

Tidy

Registered User.
Local time
Tomorrow, 03:15
Joined
May 9, 2011
Messages
16
Good Morning To All,
I am having a problem an excel pivot chart that I'm building using data from Access. I am putting 3 graphs in one worksheet, but when I add the second sheet the ".SetSourceData" is not working correctly. This is causing my 2nd Graph to link to my first graph. The below code is what I'm using to set the first graph and it works correctly.

Code:
    objxlBook.PivotCaches.Create(1, "FY 10 BASE!R3C2:R29C11").CreatePivotTable "R7C2", "FY 10 PIVOT CHART", defaultversion:=3
    objExcel.ActiveWorkbook.ShowPivotChartActiveFields = False
    objxlSheet.Shapes.AddChart.Select
    objExcel.ActiveChart.SetSourceData Range("'FY 10 CHART'!$A$5:$J$27")
    objExcel.ActiveChart.ChartType = xlColumnClustered

This is the code I'm using to pull in my second chart
Code:
    objxlBook.PivotCaches.Create(1, "FY 10 BASE!R3C2:R29C11").CreatePivotTable "R7C12", "FY 10 PIVOT CHART 2", defaultversion:=3
    objExcel.ActiveWorkbook.ShowPivotChartActiveFields = False
    objxlSheet.Shapes.AddChart.Select
    objExcel.ActiveChart.SetSourceData Range("'FY 10 CHART'!$L$5:$N$22")
    objExcel.ActiveChart.ChartType = xlColumnClustered

When I run this code I get the error "Run-Time Error -2147467259(80004005) Method'SetSourceData' of object'_Chart Failed"

I have tried everything I could think of to solve this problem, but with no luck. Can some please assist me with this issue.
 

Users who are viewing this thread

Back
Top Bottom