Visual Basic Chart Objects array

J

Jim Thomlinson

When you are dealing with objects such as charts you are better off witha
collection than an array... Try something like this...

Sub test()
Dim colCharts As Collection
Dim cht As ChartObject

Set colCharts = New Collection

colCharts.Add Sheet1.ChartObjects(1), "Chart1"
colCharts.Add Sheet2.ChartObjects(1), "Chart2"

For Each cht In colCharts
MsgBox cht.Name
Next cht
End Sub
 
J

Jon Peltier

I've used arrays. It depends why the user needs an array or collection of
charts.

- Jon
 
J

Jim Thomlinson

Being that you are the charts guru I will defer to your answer. Normally when
I describe storing objects in a collection I premise the answer with
"usually" a collection is better. That being said when would you prefer an
array? While I recognize that you can do it I am hard pressed to see an
advantage.
 
J

Jon Peltier

I don't know if there's an advantage of arrays over collections. I started
out using arrays before I understood collections, and I've never converted
the old code.

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top