BrianExcel
Well-known Member
- Joined
- Apr 21, 2010
- Messages
- 975
I am trying to add a chart via VBA. The workbook I am working in is an add-in, but the data sources for the chart exist in the workbook and work properly. If I add the chart manually via Insert > Chart > etc., it works fine.
However, when I try to add the chart, I continually get a "Compile Error: Invalid or unqualified reference" error.
Here is the code I am using..
Any thoughts on why this won't work?
However, when I try to add the chart, I continually get a "Compile Error: Invalid or unqualified reference" error.
Here is the code I am using..
VBA Code:
Sub Apply_Graph_Formatting(controlo As IRibbonControl)
Dim VenueColumn As Long
Dim PercentColumn As Long
VenueColumn = .Cells(Rows.Count, "A").End(xlUp).Row
PercentColumn = .Cells(Rows.Count, "D").End(xlUp).Row
ActiveWorkbook.Activeworksheet.Shapes.AddChart(201, xlColumnClustered).Select
ActiveChart.ApplyChartTemplate ("C:\Users\brian.david\AppData\Roaming\Microsoft\Templates\Charts\OpsReviewHistogramTemplate.crtx")
ActiveChart.SetSourceData Source:=Range(VenueColumn, PercentColumn)
End Sub
Any thoughts on why this won't work?