Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default VBA Excel - changing series source.

No, With/End With is a very handy construction in VB, and can be used anywhere a
block of code would otherwise have lots of repetition of the same object references.

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

Nick Bennett wrote:

Jon Peltier wrote in message ...

Nick -

SetSourceData tells the chart what its entire range should be. This is fine if the ranges are
all neatly aligned, and all series use the same range for their X values.



Thanks for that: it's what I suspected, hence the need for some kind
of series-specific code!


What you need is to set the X and Y ranges for each series separately:

With Chart(1).SeriesCollection(1)
.Values = Worksheets("DataSet").Range("AI3:AI28")
.XValues = Worksheets("DataSet").Range("AH3:AH28")
.Name = Worksheets("DataSet").Range("AI2")
End With



With a little tweaking I think I've got it to work: minor hiccup
though, it should read

With ChartS(1)...

which had me head-scratching for a bit ;-)

I was under the impression that the With commands were only for
setting up a chart at the start of a program or something, but it
seems reasonably happy with changing it on the fly.

Note for any readers with the same/similar problems that I expect it
only works if you've already established a series the the sort of
errors I was getting imply that unless you've previously established a
NewSeries with a range etc you can't then go in and change it - since
my chart and series pre-exists that criteria is filled. This is
probably obvious to anyone with much experience with VBA but I'm
learning as I go!

I'm pretty sure I should be okay from here on. Thanks very much for
the assistance.

Cheers

Bennett


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
Excel 2000: Changing path of an external data source Craig Excel Discussion (Misc queries) 1 December 11th 07 05:03 PM
Changing a Data Source in Excel 2000 Thomas Crymes Excel Discussion (Misc queries) 1 November 21st 06 08:49 PM
Changing series information for approximately 60 series in a workb Barb Reinhardt Charts and Charting in Excel 2 January 18th 06 10:22 PM
Excel changing number formatting and source data in graphs on it's own!!! JohnHamer Excel Discussion (Misc queries) 2 September 22nd 05 02:29 PM
VBA Excel - changing series source. Nick Bennett[_2_] Excel Programming 0 September 24th 04 09:00 PM


All times are GMT +1. The time now is 02:20 PM.

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"