Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

name of a bar chart in Excel?

Status
Not open for further replies.

kingz2000

Programmer
May 28, 2002
304
DE

Hi,

Having a dynamic amount of bar charts in an excelfile which I would like to control via VBA, how do I refer to a particular bar chart?

The problem with index is that there is a dynamically controlled no. of bar charts in the xcelfile and I need to somehow refer to them via name.Is there someways of doing this or only via Index number??

Thanks in advance.

Kingsley
 


Are these charts in a worksheet or separate chart sheets?

BTW, If these charts are basically all the same except for the source data for the series, you can dramatically reduce maintenance by having ONE CHART, controlling the source data with controls like a drop down or spinner.

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
The charts are all in 1 work sheet.

Well, there about 5 different charts with 5 different datasources..This number could vary in fact from 5 to 8 depending on the templates which I use to copy the numerous report-pages, which are dependent on the amount of data for a particular month.

 


Take a look at Charts & VBA faq707-4811.

Since you have 5 charts in a sheet, be aware of this...

You have 5 ChartObject Objects.

Each ChartObject has a Chart Property.

To reference the 5 charts, you will need code like this...
Code:
Sub test()
  Dim cho As ChartObject
  For Each cho In ActiveSheet.ChartObjects
    MsgBox cho.Name
    MsgBox cho.Chart.Name
    With cho.Chart
      'here's where you do stuff to your chart
      
    End With
  Next

End Sub


Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top