![]() |
Visual Basic Chart Objects array
Can anyone tell me how to set an array of charts within Visual Basic?
Thanks |
Visual Basic Chart Objects array
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 -- HTH... Jim Thomlinson "CloudDoctor" wrote: Can anyone tell me how to set an array of charts within Visual Basic? Thanks |
Visual Basic Chart Objects array
I've used arrays. It depends why the user needs an array or collection of
charts. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Jim Thomlinson" wrote in message ... 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 -- HTH... Jim Thomlinson "CloudDoctor" wrote: Can anyone tell me how to set an array of charts within Visual Basic? Thanks |
Visual Basic Chart Objects array
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. -- HTH... Jim Thomlinson "Jon Peltier" wrote: I've used arrays. It depends why the user needs an array or collection of charts. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Jim Thomlinson" wrote in message ... 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 -- HTH... Jim Thomlinson "CloudDoctor" wrote: Can anyone tell me how to set an array of charts within Visual Basic? Thanks |
Visual Basic Chart Objects array
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 ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Jim Thomlinson" wrote in message ... 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. -- HTH... Jim Thomlinson "Jon Peltier" wrote: I've used arrays. It depends why the user needs an array or collection of charts. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Jim Thomlinson" wrote in message ... 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 -- HTH... Jim Thomlinson "CloudDoctor" wrote: Can anyone tell me how to set an array of charts within Visual Basic? Thanks |
All times are GMT +1. The time now is 04:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com