BrianExcel
Well-known Member
- Joined
- Apr 21, 2010
- Messages
- 975
I am creating a chart using the following code:
However, every time I run the code to add the chart (which runs successfully), it adds the chart with a name that increases 1 each time. So the first time I created the chart is was named Chart 1, then the next time Chart 2, etc.
Once the chart is created, I need to rename it as "Edits" so I can then refer to it in code to assign a specific height and width.
I tried "Charts.Name" but it errored out. ANy ideas?
VBA Code:
Sub Apply_Graph_Formatting(control As IRibbonControl)
Range("Sum7EditsTable[[#All],[Venue]]").Select
ActiveWorkbook.Names.Add Name:="VenueColumn", RefersToR1C1:="=Sum7EditsTable[[#All],[Venue]]"
Range("Sum7EditsTable[[#All],[Percent Edit]]").Select
ActiveWorkbook.Names.Add Name:="PercentColumn", RefersToR1C1:="=Sum7EditsTable[[#All],[Percent Edit]]"
ActiveWorkbook.ActiveSheet.Shapes.AddChart(201, xlColumnClustered).Select
ActiveChart.ApplyChartTemplate ("C:\Users\brian.burdette\AppData\Roaming\Microsoft\Templates\Charts\OpsReviewHistogramTemplate.crtx")
End Sub
However, every time I run the code to add the chart (which runs successfully), it adds the chart with a name that increases 1 each time. So the first time I created the chart is was named Chart 1, then the next time Chart 2, etc.
Once the chart is created, I need to rename it as "Edits" so I can then refer to it in code to assign a specific height and width.
I tried "Charts.Name" but it errored out. ANy ideas?