arc90 lab | tools: Link Thumbnail
Excel Help Forum
ExcelTip.com
Account Icon Account Icon Account Icon
ExcelTip.com

Go Back   Excel Help Forum > Microsoft Office Application Help - Excel Help forum > Excel Programming > Excel Charting

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-28-2005, 04:05 PM
Richo via OfficeKB.com
Guest
 
Posts: n/a
Chart Series using non-contiguous calls in VBA

I'm trying to create charts in Excel from a bunch of non-contiguous cells
using VBA.

The cells are Sheet1!$C1:C2,Sheet1!$C4:C5,Sheet1!$C6:C7,Sheet1!$C9:C10, etc.

I first tried to set Series.Formula with a string that I generated from the
sheet & cell names, but I had enough cells that I hit that 250 character
limit in the Series.Formula arguments.

I tried a number of other tactics, including:
Trying SeriesCollection.Extend (didn't work, since I'm trying to put
data from >1 sheet into the chart)
Trying to just set Series.Values & Series.XValues separately
Applying a name to the renge I wanted to plot, & feeding that into .
Formula, then .Values
(I can't remember what else)

After all this, I found out something absolutely maddening

So maddening indeed that I may be without teeth & hair by the end of the day.

I can:
1 select the series manually with the mouse, and select the "Source
Data" context menu
2 type "=Sheet!NamedRange" into the Values field & hit OK
3 see that the plot has the right data
4 manually select the series again & copy the text of the series
fomula from the formula bar
5 paste said text into VBA code that sets Series.Formula
6 FLIP MY FREAKIN LID BECAUSE THE CODE DOESN'T WORK!!!!

Richo.Breathe.Value = xlSlowly
Richo.Wait(10)

Anyway, does anyone know why this doesn't work? Am I doing something wrong,
or do multi-area ranges somehow work in Excel, but not in VBA?

Obviously I can always make a new sheet specifically for the chart data, but
that somehow seems inelegant...

Any help / kind words are appreciated,

Richo
Reply With Quote
  #2  
Old 10-28-2005, 11:05 PM
Jon Peltier
Guest
 
Posts: n/a
Re: Chart Series using non-contiguous calls in VBA

Richo -

> Obviously I can always make a new sheet specifically for the chart
> data, but that somehow seems inelegant...


My point of view on this is: if it works, it's elegant. I much prefer
making a separate sheet or range for the data. It makes it easier to run
in the first place, and figure out what's wrong in the second, and it
usually is much faster than working through the more classically elegant
formulations. You can always hide the worksheet if you think you'll be
ashamed!

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Richo via OfficeKB.com wrote:

> I'm trying to create charts in Excel from a bunch of non-contiguous cells
> using VBA.
>
> The cells are Sheet1!$C1:C2,Sheet1!$C4:C5,Sheet1!$C6:C7,Sheet1!$C9:C10, etc.
>
> I first tried to set Series.Formula with a string that I generated from the
> sheet & cell names, but I had enough cells that I hit that 250 character
> limit in the Series.Formula arguments.
>
> I tried a number of other tactics, including:
> Trying SeriesCollection.Extend (didn't work, since I'm trying to put
> data from >1 sheet into the chart)
> Trying to just set Series.Values & Series.XValues separately
> Applying a name to the renge I wanted to plot, & feeding that into .
> Formula, then .Values
> (I can't remember what else)
>
> After all this, I found out something absolutely maddening
>
> So maddening indeed that I may be without teeth & hair by the end of the day.
>
> I can:
> 1 select the series manually with the mouse, and select the "Source
> Data" context menu
> 2 type "=Sheet!NamedRange" into the Values field & hit OK
> 3 see that the plot has the right data
> 4 manually select the series again & copy the text of the series
> fomula from the formula bar
> 5 paste said text into VBA code that sets Series.Formula
> 6 FLIP MY FREAKIN LID BECAUSE THE CODE DOESN'T WORK!!!!
>
> Richo.Breathe.Value = xlSlowly
> Richo.Wait(10)
>
> Anyway, does anyone know why this doesn't work? Am I doing something wrong,
> or do multi-area ranges somehow work in Excel, but not in VBA?
>
> Obviously I can always make a new sheet specifically for the chart data, but
> that somehow seems inelegant...
>
> Any help / kind words are appreciated,
>
> Richo

Reply With Quote
Reply

Bookmarks

New topics in Excel Charting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


All times are GMT -4. The time now is 06:06 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0