acces Chart by name..

jamiguel77

Active Member
Joined
Feb 14, 2006
Messages
387
Office Version
  1. 2016
  2. 2010
  3. 2007
Platform
  1. Windows
  2. Web
Hi i have this code that create a chart nto a workbook:

Set rng = Range("A24:B26")

Set cht = NewSheet.ChartObjects.Add( _
Left:=200, _
Width:=370, _
Top:=290, _
Height:=260)
'cht.Chart.ChartType = xlPie
cht.Chart.SetSourceData Source:=rng
'cht.Chart.ChartType = xlPie
cht.Chart.ChartType = xlDoughnut
cht.Chart.HasTitle = True
cht.Chart.ChartTitle.Text = "Actual"
'cht.Chart.SetElement msoElementDataLabelBestFit
cht.Chart.SetElement msoElementDataLabelCallout
cht.Chart.Name = "Actual"


i have other 3 charts...

Tha chart name is Unique.....


i need declare this variable:

Dim MyChart As Chart


But how to assign the Chart: cht.Chart.Name = "Actual" to my variable: MyChart ?


thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
In your macro I had to replace
Code:
[FONT=Verdana]cht.Chart.Name = "Actual"[/FONT]
by
Code:
[FONT=Verdana]cht.Name = "Actual"[/FONT]
to get it named.

Then
Code:
[FONT=inherit]Set MyChart [FONT=inherit]=[/FONT][FONT=inherit] ActiveSheet[/FONT][FONT=inherit].[/FONT][FONT=inherit]Shapes[/FONT][FONT=inherit]("Actual")[/FONT][/FONT]
would work
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top