Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Visual Basic Chart Objects array

Can anyone tell me how to set an array of charts within Visual Basic?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Chart Moving playerbigdog Excel Programming 11 June 6th 08 05:28 PM
extending a chart with visual basic Denis[_4_] Excel Programming 1 December 2nd 06 03:19 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
visual basic & chart data labels LES Excel Programming 1 July 22nd 05 04:15 PM
How do I use an array function in Visual basic .NET? cirrus Excel Programming 1 October 22nd 04 04:23 PM


All times are GMT +1. The time now is 04:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"