Hello,
I can't seem to find this anywhere for some reason but how do you name a chart. When I use the macro recorder I see they get named Chart 1, Chart 2 etc.
I have a macro to create a chart that works the first time around, but will create a new chart each time it is run. I want it to just update, but can't figure out how to get the name of the chart to reference it.
1) How do I give the chart a specific name?
2) How do I use .find to see if it is already there.
3)What property defines the charts location on the screen.
Thanks as usual...
If I can't search for it, but can name it I can just select it, delete it and re-make it.
I can't seem to find this anywhere for some reason but how do you name a chart. When I use the macro recorder I see they get named Chart 1, Chart 2 etc.
I have a macro to create a chart that works the first time around, but will create a new chart each time it is run. I want it to just update, but can't figure out how to get the name of the chart to reference it.
Code:
'Make Chart
Set d = .Find(Hours_Chart, [COLOR=red]LookIn:???)[/COLOR]
[COLOR=seagreen]'If the chart hasn't been created, then create it.[/COLOR]
[COLOR=black]If d Is Nothing Then[/COLOR]
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.ApplyLayout (5)
ActiveWindow.SmallScroll Down:=0
ActiveChart.SetSourceData Source:=Range(("O3"), Range _
("P3").End(xlDown))
[COLOR=red]Need to name chart as "Hours_Chart" so that below I can refer to it.[/COLOR]
[COLOR=seagreen]'Otherwise if it is present, then update it.[/COLOR]
Else:
[COLOR=seagreen]'Chart you are updating[/COLOR]
ActiveSheet.ChartObjects("Hours_Chart").Activate
[COLOR=seagreen]' Set range data[/COLOR]
Set rngChartdata = Sheets("Hours Log").Range(("O3"), Range _
("P3").End(xlDown))
ActiveChart.SetSourceData Source:=rngChartdata, _
PlotBy:=xlColumns
End If
1) How do I give the chart a specific name?
2) How do I use .find to see if it is already there.
3)What property defines the charts location on the screen.
Thanks as usual...
If I can't search for it, but can name it I can just select it, delete it and re-make it.