NicoleJones
01-30-2011, 01:57 PM
Hi
I have written code that inserts and formats a chart. (below)
Sub CreateDoughnutChart()
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$F$4:$F$14")
With ActiveChart
.ChartType = xlDoughnut
.ChartArea.Copy
.Paste
End With
With ActiveChart.SeriesCollection(1)
.Select
.ApplyDataLabels
End With
ActiveChart.SeriesCollection(2).Select
ActiveChart.ChartGroups(1).DoughnutHoleSize = 65
'Changes the label fill to clear
ActiveSheet.ChartObjects("Chart 26").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Interior
.Pattern = xlNone
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.Weight = xlThin
.Color = xlNone
End With
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.SetElement (msoElementChartTitleAboveChart)
End Sub
How do I write the code to find out what 'Name' the chart has just been called? So that it can be automated, at the moment I have to change the name everytime while I am testing.
Thank you for your assistance
Nicole
I have written code that inserts and formats a chart. (below)
Sub CreateDoughnutChart()
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$F$4:$F$14")
With ActiveChart
.ChartType = xlDoughnut
.ChartArea.Copy
.Paste
End With
With ActiveChart.SeriesCollection(1)
.Select
.ApplyDataLabels
End With
ActiveChart.SeriesCollection(2).Select
ActiveChart.ChartGroups(1).DoughnutHoleSize = 65
'Changes the label fill to clear
ActiveSheet.ChartObjects("Chart 26").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Interior
.Pattern = xlNone
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.Weight = xlThin
.Color = xlNone
End With
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.SetElement (msoElementChartTitleAboveChart)
End Sub
How do I write the code to find out what 'Name' the chart has just been called? So that it can be automated, at the moment I have to change the name everytime while I am testing.
Thank you for your assistance
Nicole